Facing Problem while solving Linear Equations simultaneously

These are my Five Equations
syms a2 a3 a4 a5 a6
EQ_01=a2 +9*a3 + 72*a4 + 540*a5 + 3888*a6 == -121/36000
EQ_02=a3+ a2/12 +9*a4 +72*a5 +540*a6 == -1049/7776000
EQ_03=a4 + (5*a2)/648 + (5*a3)/48 + (25*a5)/3 + (450*a6)/7 == -2987/419904000
EQ_04 =a5 + (7*a2)/8640 + (7*a3)/600 + (7*a4)/60 + (63*a6)/8 == -19789/41990400000
EQ_05 =a6 + a2/10800 + a3/720 + a4/70 + a5/8 == -24163/661348800000
i am trying to solve for the variables a2 , a3, a4 , a5 & a6
here is my code
sol = solve([EQ_01, EQ_02, EQ_03, EQ_04, EQ_05],[a2,a3,a4,a5,a6])
and i got fallowing error
1---Second argument must be a vector of symbolic variables.
2----[eqns, vars] = sym.getEqnsVars(argv{:});
3----[eqns,vars,options] = getEqns(varargin{:});
4----Error in Rayleigh_Ritz_Method (line 104)
sol = solve([EQ_01, EQ_02, EQ_03, EQ_04, EQ_05],[a2,a3,a4,a5,a6]);

 채택된 답변

The only correction required to get this to run is to add the syms declaration —
syms a2 a3 a4 a5 a6
EQ_01=a2 +9*a3 + 72*a4 + 540*a5 + 3888*a6 == -121/36000
EQ_01 = 
EQ_02=a3+ a2/12 +9*a4 +72*a5 +540*a6 == -1049/7776000
EQ_02 = 
EQ_03=a4 + (5*a2)/648 + (5*a3)/48 + (25*a5)/3 + (450*a6)/7 == -2987/419904000
EQ_03 = 
EQ_04 =a5 + (7*a2)/8640 + (7*a3)/600 + (7*a4)/60 + (63*a6)/8 == -19789/41990400000
EQ_04 = 
EQ_05 =a6 + a2/10800 + a3/720 + a4/70 + a5/8 == -24163/661348800000
EQ_05 = 
sol = solve([EQ_01, EQ_02, EQ_03, EQ_04, EQ_05],[a2,a3,a4,a5,a6])
sol = struct with fields:
a2: -265660443171156185011/26563311466141754327040 a3: 36806947866579283561/39844967199212631490560 a4: 8376188234952364463/956279212781103155773440 a5: -76519827268723512571/14344188191716547336601600 a6: 21255507574645885373/143441881917165473366016000
Note that the error message flagged exactly that problem (that the symbolic variables had not been declared first).
.

댓글 수: 6

issue not resolved same error came again
Let's make sure you're calling the correct solve function. What does this command show when you run it in your MATLAB session?
which -all solve
/MATLAB/toolbox/pde/@femodel/solve.m % femodel method /MATLAB/toolbox/symbolic/symbolic/@sym/solve.m % sym method
>> which -all solve
D:\Installation Software\matlab\toolbox\symbolic\symbolic\@sym\solve.m % sym method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgdivexpr\solve.m % cgdivexpr method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgexpr\solve.m % cgexpr method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgfeature\solve.m % cgfeature method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgsubexpr\solve.m % cgsubexpr method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgvalue\solve.m % cgvalue method
D:\Installation Software\matlab\toolbox\mbc\mbcexpr\@cgvariable\solve.m % cgvariable method
It works here (R2024a) and should also work in all recent versions/releases.
Copy and paste this as the first line of your code:
syms a2 a3 a4 a5 a6
so the entire code is now:
syms a2 a3 a4 a5 a6
EQ_01=a2 +9*a3 + 72*a4 + 540*a5 + 3888*a6 == -121/36000
EQ_02=a3+ a2/12 +9*a4 +72*a5 +540*a6 == -1049/7776000
EQ_03=a4 + (5*a2)/648 + (5*a3)/48 + (25*a5)/3 + (450*a6)/7 == -2987/419904000
EQ_04 =a5 + (7*a2)/8640 + (7*a3)/600 + (7*a4)/60 + (63*a6)/8 == -19789/41990400000
EQ_05 =a6 + a2/10800 + a3/720 + a4/70 + a5/8 == -24163/661348800000
sol = solve([EQ_01, EQ_02, EQ_03, EQ_04, EQ_05],[a2,a3,a4,a5,a6])
That should work, as it does again here —
syms a2 a3 a4 a5 a6
EQ_01=a2 +9*a3 + 72*a4 + 540*a5 + 3888*a6 == -121/36000;
EQ_02=a3+ a2/12 +9*a4 +72*a5 +540*a6 == -1049/7776000;
EQ_03=a4 + (5*a2)/648 + (5*a3)/48 + (25*a5)/3 + (450*a6)/7 == -2987/419904000;
EQ_04 =a5 + (7*a2)/8640 + (7*a3)/600 + (7*a4)/60 + (63*a6)/8 == -19789/41990400000;
EQ_05 =a6 + a2/10800 + a3/720 + a4/70 + a5/8 == -24163/661348800000;
sol = solve([EQ_01, EQ_02, EQ_03, EQ_04, EQ_05],[a2,a3,a4,a5,a6])
sol = struct with fields:
a2: -265660443171156185011/26563311466141754327040 a3: 36806947866579283561/39844967199212631490560 a4: 8376188234952364463/956279212781103155773440 a5: -76519827268723512571/14344188191716547336601600 a6: 21255507574645885373/143441881917165473366016000
format longE
a2 = double(sol.a2)
a2 =
-1.000102880658436e-02
a3 = double(sol.a3)
a3 =
9.237540009144899e-04
a4 = double(sol.a4)
a4 =
8.759144947417897e-06
a5 = double(sol.a5)
a5 =
-5.334552659655709e-06
a6 = double(sol.a6)
a6 =
1.481820183237729e-07
.
thanks now its working
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R2021b

질문:

2024년 3월 21일

댓글:

2024년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by