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?
采纳的回答
更多回答(3 个)
Ali Al-khadher
2019-3-14
%{
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 个评论
Timothy Beckham
2021-7-21
编辑:Timothy Beckham
2021-7-21
I am grateful for the solution. I was looking for something similar and came across this page. Thank you very much!
SHREY VERMA
2021-8-26
0 个投票
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Linear Algebra 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!