필터 지우기
필터 지우기

Cumulative sum doesn't work.

조회 수: 1 (최근 30일)
Carmela Marie Lingad
Carmela Marie Lingad 2021년 5월 24일
댓글: Rik 2021년 6월 9일
Hi. I uploaded my code and the excel file. I have a concern.
I want to compute for parameter YB1. To compute for the YB1, it should be the product of the corresponding Wt1 and (Db1 - Da1). But there is a condition. The computation of YB1 should start in the value where Da1 = Df1 and should end where Db1 = Df1 + B1. So based on the excel file,
Df1 = 3m, B1 = 1.2m
Since cell B9 is equals to (Df1 = 3m) and cell C10 is equals to (Df1 + B1 = 3m + 1.2m = 4.2m).
Therefore, YB1 = cell E9(cell C9 - cell B9) + cellE10(cell C10 - cell B10).
YB1 = 9(4-3) + 9.133333(4.2 - 4)
So the condition should be this, the cumulative sum of the product of Wt1 and (Db1 - Da1) should start where Da1 = Df1 and should end where Db1 = Df1 + B1.
Then the return value should be the sum of YB1. And it should be written consistently from cell G5 to cell G35. The cumulative sum will be written from cell G5:G35.
I hope someone can help me.
  댓글 수: 4
Carmela Marie Lingad
Carmela Marie Lingad 2021년 6월 9일
Hi. I would like to follow up this question. I still can't figure out the code.
Rik
Rik 2021년 6월 9일
How doesn't the code David posted work for you?

댓글을 달려면 로그인하십시오.

채택된 답변

David Hill
David Hill 2021년 5월 24일
편집: David Hill 2021년 5월 24일
t=readmatrix('Terzaghi2.xlsx');%load matrix and look where everything is at
a=t(2,7);
b=t(1,7)+a;
idx1=find(t(:,2)==a);
idx2=find(t(:,3)==b);
Yb=cumsum(t(idx1:idx2,5).*(t(idx1:idx2,3)-t(idx1:idx2,2)));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by