Borrar filtros
Borrar filtros

how to solve a simultaneous equation of 2 variables.

119 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Mzo. de 2013
If you have the Symbolic toolbox,
syms x y
solve(x + 3*y - 5, 2*x + 4*y - 4)
  2 comentarios
Sivakumaran Chandrasekaran
Sivakumaran Chandrasekaran el 30 de Mzo. de 2013
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
Mandar Parkhi
Mandar Parkhi el 11 de Feb. de 2018
hi walter, how to get symbolic toolbox ?

Iniciar sesión para comentar.

Más respuestas (3)

Anand
Anand el 30 de Mzo. de 2013
A = [1 3;...
2 4;];
b = [5;...
4];
%Solve Ax=b as A\b
X = A\b
>> A\b
ans =
-4
3

Ali Al-khadher
Ali Al-khadher el 14 de Mzo. de 2019
%{
ax+by=c....equ(1)
dx+ey=f....equ(2)
A=[a b;d e]
B=[c f]
sol=A/B
x=sol(1)
y=sol(2)
example
3x-9y=-42....equ(1)
2x+4y=2......equ(2)
%}
A = [3 -9;2 4]
b = [-42;2]
%Solve Ax=b as A\b
sol=A\b;
x=sol(1)
y=sol(2)
  1 comentario
Timothy Beckham
Timothy Beckham el 21 de Jul. de 2021
Editada: Timothy Beckham el 21 de Jul. de 2021
I am grateful for the solution. I was looking for something similar and came across this page. Thank you very much!

Iniciar sesión para comentar.


SHREY VERMA
SHREY VERMA el 26 de Ag. de 2021
You can use this file for solving 2, 3, 4 or more variable for solving linear equation, which may consist of real or complex number.

Etiquetas

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by