i need help figuring out the code to solve 6 non linear equation

Here is my code:
syms a b c d e f
oBal=(-a*2) + c*2 + d*2 + e*2+f*1==0;
cBal=c*4+e*1==6;
hBal=c*7+d*8+f*2-(12+b*3)==0;
nBal=(-b*1)+c*1==0;
Rq=e/a==1.3;
Y=(c*101.1039)/(112.1265)==0.5;
sol=solve(oBal,cBal,hBal,nBal,Rq,Y);
sol.a;
sol.b;
sol.c;
sol.d;
sol.e;
sol.f;
disp(a)
disp(b)
disp(c)
disp(d)
disp(e)
disp(f)

 Accepted Answer

Hi,
your code is ok - just convert the symbolic results to numeric:
syms a b c d e f
oBal=(-a*2) + c*2 + d*2 + e*2+f*1==0;
cBal=c*4+e*1==6;
hBal=c*7+d*8+f*2-(12+b*3)==0;
nBal=(-b*1)+c*1==0;
Rq=e/a==1.3;
Y=(c*101.1039)/(112.1265)==0.5;
sol=solve(oBal,cBal,hBal,nBal,Rq,Y);
format long
sol_a = double(sol.a)
sol_b = double(sol.b)
sol_c = double(sol.c)
sol_d = double(sol.d)
sol_e = double(sol.e)
sol_f = double(sol.f)
format short
gives:
sol_a =
2.909196152898918
sol_b =
0.554511250307852
sol_c =
0.554511250307852
sol_d =
3.872758845869675
sol_e =
3.781954998768593
sol_f =
-10.600057884094404
Best regards
Stephan

More Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Products

Release

R2018a

Community Treasure Hunt

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

Start Hunting!