Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

how to solve a simultaneous equation of 2 variables.

Asked by Sivakumaran Chandrasekaran on 30 Mar 2013

x+3y=5;2x+4y=4. In general maths, we can be able to find the values of 'x' and 'y' from the above equations. How to find it in MATLAB?

0 Comments

Sivakumaran Chandrasekaran

Tags

Products

2 Answers

Answer by Walter Roberson on 30 Mar 2013

If you have the Symbolic toolbox,

syms x y
solve(x + 3*y - 5, 2*x + 4*y - 4)

1 Comment

    x: [1x1 sym]
    y: [1x1 sym]. this is the answer which i got.. but i want to know the value of x and y.. no values are stored in workspace also
Walter Roberson
Answer by Anand on 30 Mar 2013
A = [1 3;...
     2 4;];
b = [5;...
     4];
%Solve Ax=b as A\b
X = A\b
>> A\b
ans =
      -4
       3

Read more here: http://www.mathworks.com/help/matlab/ref/mldivide.html

0 Comments

Anand

Contact us