solve non linear equations

3 Ansichten (letzte 30 Tage)
sunitha
sunitha am 15 Jan. 2021
Kommentiert: Alan Stevens am 16 Jan. 2021
i wrote the code for non linear equations. But i got the error .can u please tell me how to rectify this error
lear all
close all
syms S J
Qo=26560 %%m3/day
R=0.56
So=220
V=2434.67 %%
X=3000
Ks=0.27
k=1.076
Y=0.39
kd=0.04
bs=0.15
Xf=0.49
Df=1.04
Dw=1.3
L=0.04
a=2.24
bt=kd+bs
Smin=Ks/((Y*k/bt)-1)
Lstar=L*(sqrt(k*Xf/Ks*Df))*Df*Dw
Sstar=S/Ks
jstar=(J/sqrt(Ks*k*Xf*Df))
Sstar_min=(1/(Y*k*(bt-1)))
r=(So-S)/So
eqn1=Qo*(1+R)*(1-r)*(So-S)-a*V*J==0;
eqn2=sqrt((Lstar^1.76)+5.2*(Sstar-Sstar_min)-(Lstar^0.88))/2.6==jstar^0.88;

Antworten (2)

KSSV
KSSV am 15 Jan. 2021
Replace the first line:
lear all
with
clear all
Also terminate the output of each line using ;
  2 Kommentare
sunitha
sunitha am 15 Jan. 2021
But still I am getting the error
KSSV
KSSV am 15 Jan. 2021
what error? IT looks you want to find S, J using eqn1, eqn2.. show the ocde which gave error.

Melden Sie sich an, um zu kommentieren.


Alan Stevens
Alan Stevens am 15 Jan. 2021
Add these lines at the end to get the values of S and J
Soln = vpasolve([eqn1, eqn2],[S, J],[1 1]);
disp(Soln.S)
disp(Soln.J)
  4 Kommentare
sunitha
sunitha am 16 Jan. 2021
Thank you,
one more doubt is that i am solving non linear equations, i wrote the code for this and i didnt get any errors but i am getting the wrong values.and i want to write the values in excel using matlab data .can u help me with this??
clear all
close all
syms N
Qo=26,560
R=0.56
No=xlsread('suspended','Sheet1','C2:C5')
X=xlsread('suspended','Sheet1','F2:F5')
r=(No-N)/No;
V=2435;
k=1.076;
Kn=0.27;
nX=size(X,1);
solutions=cell(nX,1);
for S=1:nX
solutions{S}=solve(Qo.*(1+R).*(No(S)-N)*r(S)-V*((X(S)*k*N)/(Kn+N)),N);
vpa(solutions{S})
end
xlswrite('S',Sheet1,'I')
Alan Stevens
Alan Stevens am 16 Jan. 2021
Well, the following gets results and writes to an Excel spreadsheet
syms N
Qo=26560;
R=0.56;
No=xlsread('suspended','Sheet1','C2:C5');
X=xlsread('suspended','Sheet1','F2:F5');
r=(No-N)/No;
V=2435;
k=1.076;
Kn=0.27;
nX=size(X,1);
solutions=cell(nX,1);
Nres = zeros(3,nX);
for S=1:nX
solutions{S}=solve(Qo.*(1+R).*(No(S)-N)*r(S)-V*((X(S)*k*N)/(Kn+N)),N);
Nres(:,S) = vpa(solutions{S});
end
fname = 'suspendedresults.xlsx';
xlswrite(fname,Nres)
However, I've no idea what your code is all about, so can't comment on the validity of the result.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by