MATLAB Answers

how to solve a simultaneous equation of 2 variables.

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?




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

Answer by Anand
on 30 Mar 2013

A = [1 3;...
     2 4;];
b = [5;...
%Solve Ax=b as A\b
X = A\b
>> A\b
ans =

Read more here:


Join the 15-year community celebration.

Play games and win prizes!

Learn more
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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!