Try to solve System of Linear Equations

3 ビュー (過去 30 日間)
Dai Nguyen
Dai Nguyen 2021 年 4 月 20 日
回答済み: Star Strider 2021 年 4 月 20 日
Hi
I'm trying to solve this matrix to find x and y, however, it didn't work. Please help
syms x y
eqn1 = x+y == 250;
eqn2= 10*x+45*y ==24000;
eqn3 = x+3*y ==3360;
eqn4 = 10*x+15*y ==1440;
sol = solve([eqn1, eqn2, eqn3, eqn4], [x, y]);
xSol = sol.x
ySol = sol.y

採用された回答

Star Strider
Star Strider 2021 年 4 月 20 日
One option:
syms x y
eqn1 = x+y == 250;
eqn2= 10*x+45*y ==24000;
eqn3 = x+3*y ==3360;
eqn4 = 10*x+15*y ==1440;
eqns = [eqn1; eqn2; eqn3; eqn4];
vars = symvar(eqns)
[A,b] = equationsToMatrix(eqns,vars);
B = linsolve(double(A),double(b))
x = B(1)
y = B(2)
.

その他の回答 (1 件)

David Hill
David Hill 2021 年 4 月 20 日
A=[1 1;10 45;1 3;10 15];
b=[250;24000;3360;1440];
A\b

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by