Asked by Tanjina
on 10 Oct 2013

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

*No products are associated with this question.*

Answer by Matt J
on 10 Oct 2013

Error and Error_max are sym variables, so the logical expression

Error > Error_max

cannot be evaluated.

Opportunities for recent engineering grads.

## 0 Comments