Solve system of equations by symbolic toolbox
1 view (last 30 days)
Show older comments
Hi, I'm write a program to solve a system of equations :
clc
syms L Pg1 Pg2 Pg3 Pg4 teta1 teta2 teta3 lamda1 lamda2 lamda3 lamda4 lamda5 M1 M2 M3 P12 P13 P23 ;
% Lagrange funtion
L = (7.5*Pg1+6*285+14*Pg3+10*Pg4) + lamda1*(-1000*teta1+500*teta2+500*teta3-(Pg1+285)...
+50)+ lamda2*(500*teta1-1500*teta2+1000*teta3-Pg3+60) +....
lamda3*(500*teta1+1000*teta2-1500-Pg4+300)+.....
lamda4*(teta1-0) + M1*(100/0.2 * (teta1-teta2)-126)+M2*(100/0.1 * (teta2-teta3)-130) + M3*(100/0.2*(teta1-teta3)-250);
eq1=diff(L,Pg1)
eq3=diff(L,Pg3)
eq4=diff(L,Pg4)
eq5=diff(L,teta1)
eq6=diff(L,teta2)
eq7=diff(L,teta3)
eq8=diff(L,lamda1)
eq9=diff(L,lamda2)
eq10=diff(L,lamda3)
eq11=diff(L,lamda4)
eq13=diff(L,M1)
eq14=diff(L,M2)
eq15=diff(L,M3)
[Pg1 Pg3 Pg4 teta1 teta2 teta3 lamda1 lamda2 lamda3 lamda4 M1 M2 M3]= solve (eq1,eq3,eq4,eq5,eq6,eq7,eq8,eq9,eq10,eq11,eq13,eq14,eq15)
In command window show: Warning: 12 equations in 1 variables. > In solve>mupadSolve at 206 In solve at 93 In opf at 23 Warning: Explicit solution could not be found. > In solve at 98 In opf at 23
Pg1 =
[ empty sym ]
Pg3 =
[]
Pg4 =
[]
teta1 =
[]
teta2 =
[]
teta3 =
[]
lamda1 =
[]
lamda2 =
[]
lamda3 =
[]
lamda4 =
[]
M1 =
[]
M2 =
[]
M3 =
[]
Can you tell me the solution for it ? Thank you very much !!!!
0 Comments
Answers (1)
Roger Stafford
on 26 Feb 2015
You should tell 'solve' what variables are to be regarded as the unknowns. See the documentation at:
http://www.mathworks.com/help/symbolic/solve.html
Look at the form:
[y1,...,yN] = solve(eqns,vars)
where 'vars' gives the list of unknowns. Their number should match the number of outputs.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!