Update a variable for each step along x-axis within loop

Hi there
So I'm calculating an erosion rate along a profile. For the first step, x = 1, I use an initial concentration of 0.1. My system then erodes sediment at the first step. I want to add this sediment to the initial concentration and use this updated concentration for x = 2, and so on.
For example
maxX = 100
C = 0.1
x = 1
while x < maxX
E = C * 50
C = C + E
x = x+1
end
So for x(1) :
E = 0.1*50
E = 5
Then for x(2), I want to carry out the code using the re-calculated C value, so C(2) = C(1) + Y(1) = 5.1
and then continue doing the code within the loop, recalculating C each time, all the way up to maxX.
Does anyone know how to write this?
Thank you!

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Dynamic System Models 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by