Cumulative sum for a certain condition with a starting and ending point

4 次查看(过去 30 天)
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.

回答(1 个)

Sulaymon Eshkabilov
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.
  1 个评论
Carmela Marie Lingad
Starting from %computation for parameter YB. I don't know if I input the correct code to portray the computation and conditions that I input. But I can't check if the computation is correct because whenever I try to run it, it says that the input array is empty in line 170

请先登录,再进行评论。

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by