Symbolic solution to a system of equations
2 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
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
2020 年 11 月 11 日
You can use subs() function
b_val = subs(sol.b, a, 5); % substitute a=5
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!