taking the output value is input for loops

조회 수: 1 (최근 30일)
sunitha
sunitha 2021년 1월 31일
댓글: Walter Roberson 2021년 3월 2일
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

답변 (1개)

Walter Roberson
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
No = 1×6
3000 0.0724933620740949 -7.68390497970109e-05 -7.82226156737398e-05 -7.82226420515739e-05 -7.82226420520768e-05
  댓글 수: 4
sunitha
sunitha 2021년 3월 2일
how can i modify this code??
Walter Roberson
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 CenterFile Exchange에서 Number Theory에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by