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:


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today