solve two simultaneous equations in matlab

edited November 2010 in Science & Tech
Hi,
I am trying to solve two simultaneous equations
in matlab. the equations are attached here
and the matlab code i have written is also attached here.
Please suggest us for that code.
error displayed in matlab as
??? Error using ==> solve at 77
' 0=(N21.*I).*(e1.^N21-x2.^N21)-(N11./K).*(e3.^N11-e2.^N11) ' is not a valid expression or equation.

Error in ==> sym.solve at 49
[varargout{1:max(1,nargout)}] = solve(S{:});

Error in ==> neutral_oxide_outside_1 at 27
[x1 x2]=solve(eq1,eq2,x1,x2)
Thanks in advance

Comments

  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited November 2010
    I'm pretty sure that the symbolic solver doesn't work on vectors the way you're using it. The error message seems to be stating that it can only provide the solution to one set of parameters at a time. I would try to reformulate the problem to use linear algebra, but you ought to be able to brute force a solution by looping your code and working one index of your e1, e2, e3, I, J, and K vectors at a time.
    for t=1:length(I)
      eq1=' 0=(N21*I(t))*(e1(t)^N21-x2^N21)-(N11/K(t)).*(e3(t)^N11-e2(t)^N11) ';
      [x1(t) x2(t)] = solve(eq1, eq2, x1, x2);
    end
    
    Also, eq2 isn't defined in your code. I didn't check your solve() syntax either, you may want to double-check the helpfile. The result of solve probably shouldn't use the same variable names as the syms you defined earlier.
Sign In or Register to comment.