taking the output value is input for loops
1 回表示 (過去 30 日間)
古いコメントを表示
i have written the code for non linear equations. i got the result.now i have to take output value as input for many times.Like i gave No=3000; and i got the ouput 780 now this ouput i have to give input like this 5 times i have written the code for this but i am getting the error can anyone help me
syms N J
Qo=15000;
R=0.67;
X=13000;
No=3000;
V=25345;
k=1.076;
Kn=0.27
kd=0.04
bs=0.15
Xf=0.49
Df=1.04
Dw=1.3
L=0.004
a=2.24
Y=0.39;
bt=kd+bs
Nstar=N/Kn;
Nmin=Kn/((Y*k/bt)-1);
Lstar=L*(sqrt(k*Xf/Kn*Df))*Df*Dw;
Nstar_min=(1/(Y*k*(bt-1)));
jstar=(J/sqrt(Kn*k*Xf*Df));
for i=1:5
eqn1=Qo*(1+R)*(No-N)-V*(a*J+((X*k*N)/(Kn+N)))==0;
eqn2=sqrt((Lstar^1.76)+5.2*(Nstar-Nstar_min))-(Lstar^0.88)/2.6==jstar^0.88;
soln=vpasolve([eqn1,eqn2],[N,J]);
disp(soln.N)
disp(soln.J)
No(i)=soln.N
end
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 1 月 31 日
format long g
syms N J
Qo=15000;
R=0.67;
X=13000;
No=3000;
V=25345;
k=1.076;
Kn=0.27;
kd=0.04;
bs=0.15;
Xf=0.49;
Df=1.04;
Dw=1.3;
L=0.004;
a=2.24;
Y=0.39;
bt=kd+bs;
Nstar=N/Kn;
Nmin=Kn/((Y*k/bt)-1);
Lstar=L*(sqrt(k*Xf/Kn*Df))*Df*Dw;
Nstar_min=(1/(Y*k*(bt-1)));
jstar=(J/sqrt(Kn*k*Xf*Df));
for i=1:5
eqn1=Qo*(1+R)*(No(i)-N)-V*(a*J+((X*k*N)/(Kn+N)))==0;
eqn2=sqrt((Lstar^1.76)+5.2*(Nstar-Nstar_min))-(Lstar^0.88)/2.6==jstar^0.88;
soln=vpasolve([eqn1,eqn2],[N,J]);
disp([i, soln.N, soln.J])
No(i+1)=soln.N;
end
No
4 件のコメント
Walter Roberson
2021 年 3 月 2 日
What exactly are you hoping the modified code would do for you?
What the current code appears to be doing, is trying to find a steady-state solution. It does not really make sense to say that you want to start that at an iteration after the first.
Ah, I just noticed something:
eqn1=Qo*(1+R)*(No(i)-N)-V*(a*J+((X*k*N)/(Kn+N)))==0;
J is used there
soln=vpasolve([eqn1,eqn2],[N,J]);
and solved for there
No(i+1)=soln.N;
The N solution becomes input for the next iteration.
I notice that there is no feedback of the calculated J value into the next loop. Should there be? If it were fed back in somehow, it would probably have to affect
jstar=(J/sqrt(Kn*k*Xf*Df));
At the moment, I do not see any good reason to feed J back, but it would be good to confirm that you do not want the J value to be fed back. Feeding it back would have odd effects on the equations, I think.
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!