Cumulative sum doesn't work.
Mostra commenti meno recenti
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 Commenti
Jan
il 24 Mag 2021
What is the purpose of this part:
while Db1 == Df1
c1 = cumsum(z1);
end
This is neither not entered at all, or an infinite loop.
Please explain "does not work" with any details. It is easier to solve a problem, than to guess, what the problem is.
Rik
il 7 Giu 2021
Instead of flagging your question, you could also edit it to make it clear. You have also received an answer. You can comment, explaining why it doesn't work for you.
Carmela Marie Lingad
il 9 Giu 2021
Rik
il 9 Giu 2021
How doesn't the code David posted work for you?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!