How can i solve loop?

clc;clear;close;
a2=0.002;%p=2.7;L=0.015;FA=0.35;MA=10;df=3*10^(-6);W=25*10^(-3); %filter2
%Pe=df*L/W^2; Fk=(4*a2-(a2)^2-3)/4-(log(a2))/2;
r=0.0012; fdotent = 3*10^(-10); vmed= 1/(10*(1-a2));Cddotdep=0;%Cin=0
fent=fdotent*vmed;
ad=0;% ad=(Cddotdep*t)*(p*W);a=a2+ad;S=(4*L*a)/pi*df;
Nddotmax=1.15*10^(7);
nanti=0.5; nfilt=0.5;
dt=200; n=3; %input('input:');
t=0:dt:800;
Nddotin=500;
Nddotpen=8.9;
Nddotdep=Nddotin*nfilt;
Nddotsur=Nddotdep*(1-nanti);
% Initialize 3components
Nddotexi = zeros(n+1, 1);
Nddotsur = zeros(n+1, 1);
Nddotout = zeros(n+1, 1);
Nddotexi(1)=166;
for i=1:n
Nddotexi(i+1)=((-1/dt)+r-fent+((1/dt)*(1/dt)-2*(r-fent)+((4*r)/Nddotmax)*(Nddotexi(i)+Nddotsur(i+1)-Nddotsur(i)))+(r-fent)^2)^(0.5)/(2*r/Nddotmax);
Nddotent=fdotent*vmed*Nddotexi(i+1);
Nddotout=Nddotent+Nddotpen;
end
figure(1)
plot(t,Nddotout,'r*',t,Nddotent,'k*',t,Nddotpen,'g*');
xlable=('time'); ylabel=('Bioaerosol');
hold on; grid on;
The Nddot out is not change.
Nddot is sum of Nddotent and Nddotepen.
I think Nddotent is change, cuz it consists of Nddotexi

回答(1 个)

Image Analyst
Image Analyst 2022-8-24

0 个投票

You need to index Nddotout inside the loop. Use Nddotout(i).

3 个评论

clc;clear;close;
a2=0.002;%p=2.7;L=0.015;FA=0.35;MA=10;df=3*10^(-6);W=25*10^(-3); filter2
%Pe=df*L/W^2; Fk=(4*a2-(a2)^2-3)/4-(log(a2))/2;
r=0.0012; fdotent = 3*10^(-10); vmed= 1/(10*(1-a2));Cddotdep=0;%Cin=0
fent=fdotent*vmed;
ad=0;% ad=(Cddotdep*t)*(p*W);a=a2+ad;S=(4*L*a)/pi*df;
Nddotmax=1.15*10^(7);
nanti=0.3; nfilt=0.65; %constant antimicrobial efficiency, filter efficiency is random
dt=100; n=10;
t=0:dt:800;
Nddotin=500;
Nddotpen=8.9;
Nddotdep=Nddotin*nfilt;
Nddotsur=Nddotdep*(1-nanti);
Nddotexi = zeros(n+1, 1);
Nddotsur = zeros(n+1, 1);
for i=1:n
t(i+1)=t(i)+dt;
Nddotexi(i+1)=((-1/dt)+r-fent+(1/dt)*((1/dt)-2*(r-fent)+(4*r/Nddotmax)*(Nddotexi(i)+Nddotsur(i+1)-Nddotsur(i))+(r-fent)^2)^(0.5))/(2*r/Nddotmax);
%H=(1/dt)*((1/dt)-2*(r-fent)+((4*r)/Nddotmax)*(Nddotexi(i)+Nddotsur(i+1)-Nddotsur(i)))+(r-fent)^2
Nddotent(i+1)=fdotent*vmed*Nddotexi(i+1);
Nddotout(i)=Nddotent(i+1)+Nddotpen;
plot(t(i),Nddotout,'rd',t(i),Nddotent,'k*',t(i),Nddotpen,'go');
hold on; grid on;
end
I think Nddotexi isn't update

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by