MATLAB Answers

Tanjina

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

Asked by Tanjina
on 10 Oct 2013
Latest activity Commented on by Matt J
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

  0 Comments

Products

No products are associated with this question.

1 Answer

Matt J
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.

  2 Comments

Tanjina
on 10 Oct 2013

Thank you for your reply. How can I rewrite it ?

Matt J
on 10 Oct 2013

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.


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today