フィルターのクリア

Symbolic solution to a system of equations

2 ビュー (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 4 月 1 日
コメント済み: Altug Bilge 2020 年 11 月 21 日
Can Matlab solve a system of equations like a+b=c, b=2c symbolically for b and c? The output should be c=-a, b=-2a

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 4 月 1 日
編集済み: Ameer Hamza 2020 年 4 月 1 日
In MATLAB you solve it like this using symbolic variables and solve function()
syms a b c
eq1 = a+b==c;
eq2 = b==2*c;
sol = solve([eq1 eq2])
Result:
>> sol.b
ans =
-2*a
>> sol.c
ans =
-a
  5 件のコメント
Ameer Hamza
Ameer Hamza 2020 年 11 月 11 日
You can use subs() function
b_val = subs(sol.b, a, 5); % substitute a=5
Altug Bilge
Altug Bilge 2020 年 11 月 21 日
Thank you so much!

サインインしてコメントする。

その他の回答 (1 件)

David Hill
David Hill 2020 年 4 月 1 日
syms a;
[1,-1;2,-1]\[a;0];

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by