How to change values in previous made loop?
Show older comments
Hi everyone,
I am trying to model a centrifuge with higher concentrations. My problem is that the formed pellet in a centrifuge can only have a certain volumetric fraction (cmax). I made a loop where the volumetric fraction is calculated. At the end of the centrifuge it will give values higher than cmax. Now, I want to give the excess back to the previous cell when cmax is reached. For this, I made a small loop, which calculates backwards from the end of the centrifuge to the beginning:
for i = Nr:-1:2 % Force system to give back excess to previous cells
c(i) = c(i)+excess;
if c(i)>cmax
excess = c(i)-cmax;
c(i) = cmax;
c(i-1) = c(i-1)+excess;
else
excess = 0;
end
end
However, my code seems to ignore this loop. Without this loop, I get the same values as without it and I am puzzled why.
I also added the files I work with.
Thank you very much in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations 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!