Solve function unable to compute algebraic system of equations

Hello, I am trying to solve this system of 4 equations using the solve function, however MATLAB is saying that it cannot find an explicit solution.
clc
clear all
%syms a b c d
syms ms1 mp1 ms2 mp2
g=9.8
isp1=290
isp2=320
for deltav1=5000 %%%guess
deltav2=9500-deltav1
e1=isp1*g*log((3000+ms1+mp1+ms2+mp2)/(3000+ms1+mp1+mp2))
e2=isp2*g*log((3000+ms2+mp2)/(3000+ms2))
e3=mp1/(ms1+mp1)
e4=mp2/(3000+ms2+mp2)
ans=solve(e1==deltav1, e2==deltav2, e3==0.9, e4==0.8)
end
There are four equations and four unknowns so I don't understand what the problem is. I am on MATLAB R2019B.
Any help or suggestions is greatly appreciated.

 Accepted Answer

syms ms1 mp1 ms2 mp2
g=9.8
g = 9.8000
isp1=290
isp1 = 290
isp2=320
isp2 = 320
deltav1=5000 %%%guess
deltav1 = 5000
deltav2=9500-deltav1
deltav2 = 4500
e1=isp1*g*log((3000+ms1+mp1+ms2+mp2)/(3000+ms1+mp1+mp2))
e1 = 
e2=isp2*g*log((3000+ms2+mp2)/(3000+ms2))
e2 = 
e3=mp1/(ms1+mp1)
e3 = 
e4=mp2/(3000+ms2+mp2)
e4 = 
eqn = [e1==deltav1, e2==deltav2, e3==0.9, e4==0.8].'
eqn = 
partial_mp1 = solve(eqn(1), mp1)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
partial_mp1 = 
eqn2 = subs(eqn(2:end), mp1, partial_mp1)
eqn2 = 
partial_mp2 = solve(eqn2(1), mp2)
partial_mp2 = 
eqn3 = subs(eqn2(2:end), mp2, partial_mp2)
eqn3 = 
partial_ms1 = solve(eqn3(1), ms1)
partial_ms1 = 
eqn4 = subs(eqn3(2:end), ms1, partial_ms1)
eqn4 = 
simplify(lhs(eqn4)) == rhs(eqn4)
ans = 
Which is to say that if you solve the first three equations for mp1 mp2 ms1 then the 4th equation becomes inconsistent. There are no solutions to the equations.

5 Comments

Hi walter, thank you for your response. In this case, the goal is to iterate delta v1 and thus delta v2 in order to find a solution that will work. Is there any way I could do this?
syms ms1 mp1 ms2 mp2 deltav1 deltav2
g=9.8;
isp1=290;
isp2=320;
%deltav1=5000 %%%guess
deltav2=9500-deltav1;
e1=isp1*g*log((3000+ms1+mp1+ms2+mp2)/(3000+ms1+mp1+mp2));
e2=isp2*g*log((3000+ms2+mp2)/(3000+ms2));
e3=mp1/(ms1+mp1);
e4=mp2/(3000+ms2+mp2);
eqn = [e1==deltav1, e2==deltav2, e3==0.9, e4==0.8].';
partial_mp1 = solve(eqn(1), mp1)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
partial_mp1 = 
eqn2 = subs(eqn(2:end), mp1, partial_mp1)
eqn2 = 
partial_mp2 = solve(eqn2(1), mp2)
Warning: Solutions are only valid under certain conditions. To include parameters and conditions in the solution, specify the 'ReturnConditions' value as 'true'.
partial_mp2 = 
eqn3 = subs(eqn2(2:end), mp2, partial_mp2)
eqn3 = 
partial_ms1 = solve(eqn3(1), ms1)
partial_ms1 = 
eqn4 = subs(eqn3(2:end), ms1, partial_ms1)
eqn4 = 
ans = simplify(lhs(eqn4)) == rhs(eqn4)
ans = 
deltav1num = simplify(solve(ans,deltav1))
deltav1num = 
ms2num = solve(subs(eqn4,deltav1,deltav1num),ms2)
ms2num = 
0
ms1num = simplify(subs(partial_ms1,[ms2 deltav1],[ms2num deltav1num]))
ms1num = 
mp2num = simplify(subs(partial_mp2,[ms2 deltav1],[ms2num,deltav1num]))
mp2num = 
12000
mp1num = simplify(subs(partial_mp1,[ms1 ms2 mp2 deltav1],[ms1num ms2num mp2num deltav1num]))
mp1num = 
Seems that for eqn(1), the "solution" leads to a log(0/0) expression.
Maple says the solution is
deltav1 = -3136*ln(5)+9500
mp1 = 9*ms1
mp2 = -40*(exp(-32/29*ln(5)+4750/1421)*ms1+300*exp(-32/29*ln(5)+4750/1421)-ms1)/(4*exp(-32/29*ln(5)+4750/1421)-5)
ms2 = -10*(exp(-32/29*ln(5)+4750/1421)*ms1+1500*exp(-32/29*ln(5)+4750/1421)-ms1-1500)/(4*exp(-32/29*ln(5)+4750/1421)-5)
ms1 = anything
which does seem to satisfy the equations

Sign in to comment.

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!