Cumulative sum for a certain condition with a starting and ending point
1 view (last 30 days)
Show older comments
I would like to ask for help with my code. I uploaded my code and excel file.
To explain, this is what I want to portray, The value of YB1 is highly dependent on the location of Df1 and B1. So if the Df1 and B1 changes, the value of YB1 will also change. And the value of the cumulative sum of the value should be the return value of YB1. So here's how to compute for YB1.
YB1 is the product of the Wt1 and the difference of Da1 and Db1. But there is a condition, (Wt1 .* (Db1 - Da1)) should start where Da1 is equal to Df1 and should end if the value of Df1 + B1 is reached. But since, the interval of the depth Da1 and Db1 is by 1, therefore, the end point of the condition should be the nearest value that portrays the condition Da1 <= Df1 +B1.
To give an example, for the excel file, Df1 = 3m, B1 = 1.2m. Therefore, to compute for YB1, it should be like this, the product of Wt1 and Db1 - Da1 should start where Da1 = Df1, hence
YB1 = cell9(cellC9 - cellB9) + (%since cell B10 is less than Df1 + B1) cellE10((Df1 + B1) - cellB10)
Hence, YB1 = 9(4-3) + 9.133333((3+1.2)-4)
Therefore, as you can see in the computation, YB1 is highly dependent on Df1 and B1. So, if parameter Df1 and B1 changes, the value of YB1 also changes.
I hope I explained the details well. And I hope someone can help me with the code.
0 Comments
Answers (1)
Sulaymon Eshkabilov
on 22 May 2021
Your code runs, imports some data from MS Excel file, computes something, and at the end produces some errs due to empty outputs to be exported into .xlsx file. It does write some data into your pre-existing Terzaghi2.xlsx file. However, it makes more sense to write different sheet of this file or a different file.
Your code compares column of data against a scalar, and some of your output variables are empty due to inaccurate comparisons (presumably).
So, where and in what calculations in your code are failing that you need to elaborate.
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!