Help with logic inside of a solver
Afficher commentaires plus anciens
I am using ode45 to solve a function describing the interaction between tanks in series. I have the variables C_IN and C_OUT specifing if carbon is flowing into or out of a tank at the specific time. If the mass of carbon in tank 1 drops below a lower limit, carbon must flow into tank 1 from tank 2 until a upper limit is reached. A portion of my code is below. The problem is that C_IN and C_out are reverted back to 0 for each iteration of the solver. Therefore instead of increasing to the concentration to the upper limit, C_IN switches back to 0 as soon as the carbon raises above the lower limit. How can I change my logic so that I can either keep my variables the same from the previous iteration of the solver, or otherwise restructure my code to achieve the same reslut?
C_IN = zeros(11, 1);
C_OUT = zeros(11, 1);
if x(11+i) < 20
C_IN(i/11) = 1;
C_OUT(i/11 + 1) = 1;
end
if x(11+i) > 30
C_IN(i/11) = 0;
C_OUT(i/11 + 1) = 0;
end
Dx(11+i) = C_IN(i/11)*(CF*x(11+i+ci)/T.volume*(1-j6) + j6*4) - C_OUT(i/11)*CF*x(11+i)/T.volume;
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Ordinary Differential Equations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!