Using the result as a input in the loop again
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
The Sanchi
el 29 de En. de 2020
Comentada: The Sanchi
el 29 de En. de 2020
I am writing a program for a model which capture the moiture from the air. I am new to the Matlab
I attached the program below
clear
clc
aw=0.7;
Ps=(2.339);
RH=95;
Tgas=293;
Tsol=293;
H=18.015;
A=0.25;
%membrane resistance (P/t)
P=(0.00000000001206);
t=(0.000055);
K=(P/t); %Resistivity constant
Cl=123.9;
mW=100;
for x=1:60*60;
t(x)=x;
Ms=(Cl/164.0);
Mw1(x)=(mW+M(x)/18.0); ---input the previous result (x-1 ) here again in the loop to find the result for the current loop
Y=Mw1(x)+(3*Ms);
Xw(x)=(Mw1(x)/Y);
Pvl=Xw(x)*Ps*aw;
Pva=(RH.*Ps)/100;
X=(Pva-Pvl(x));
Gv(x)=(K)*(X(x));
M(x)=Gv(x)*H*t(x)*A; ---- Result of the current loop for the next interation
end
How can I use the result from the previous loop to do the calculation in current loop. I need help.Thanks!
0 comentarios
Respuesta aceptada
Sindar
el 29 de En. de 2020
Change
Mw1(x)=(mW+M(x)/18.0);
to
% first iteration assumes Mw1(0) = 0
if x==1
Mw1(x)=mW;
% later loops access the value from the earlier iteration
else
Mw1(x)=(mW+M(x-1)/18.0);
end
Más respuestas (0)
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!