taking the output value is input for loops
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Walter Roberson
am 31 Jan. 2021
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 Kommentare
Walter Roberson
am 2 Mär. 2021
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.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!