System of Nonlinear equations-Conversion to logical from sym is not possible.

조회 수: 4 (최근 30일)
Tanjina
Tanjina 2013년 10월 10일
댓글: Matt J 2013년 10월 10일
Hello everyone,
I am a very new user of MATLAB. I am trying to solve system of equation contain linear and non linear equation.
syms x1 x2 x3 x4 x5 x6 x7
EQ1 = x1-x2-x6;
EQ2 = x2+x3-2;
EQ3 = x4+x5-x3;
EQ4 = x7+x6-x4;
EQ5 = -K2*x2*abs(x2)+K3*x3*abs(x3)+K4*x4*abs(x4)+K6*x6*abs(x6);
EQ6 = 5-K5*x5*abs(x5)-K3*x3*abs(x3)+K2*x2*abs(x2)+K1*x1*abs(x1);
EQ7 = 5-K1*x1*abs(x1)-K6*x6*abs(x6)+K7*x7*abs(x7)-(22.9-10.33*x7^2+2.823*x7)*(x7/abs(x7));
sol = solve(EQ1, EQ2, EQ3, EQ4, EQ5, EQ6, EQ7);
sol.x1
sol.x2
sol.x3
sol.x4
sol.x5
sol.x6
sol.x7
xn(1)=x1;
xn(2)=x2;
xn(3)=x3;
xn(4)=x4;
xn(5)=x5;
xn(6)=x6;
xn(7)=x7;
for i = 1: N
Error = abs((xn(i)-x(i))/x(i)) ;
if Error > Error_max
Error_max= Error;
end % if
end
This algorithm run for one time and give result for x1,x2......x7 but it does not calculate any error and gives me this message.
"Conversion to logical from sym is not possible.
Error in again (line 118) if Error > Error_max"
I don't understand how can I solve it. It will be great help if someone can help me.
Regards, Tanjina

답변 (1개)

Matt J
Matt J 2013년 10월 10일
Error and Error_max are sym variables, so the logical expression
Error > Error_max
cannot be evaluated.
  댓글 수: 2
Tanjina
Tanjina 2013년 10월 10일
Thank you for your reply. How can I rewrite it ?
Matt J
Matt J 2013년 10월 10일
You must first give non-symbolic values to the x(i). I.e., you must evaluate them numerically for a particular set of K parameters.

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

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by