フィルターのクリア

Comparing coefficients and solving equation

6 ビュー (過去 30 日間)
Jakub
Jakub 2024 年 4 月 26 日
コメント済み: Jakub 2024 年 4 月 28 日
Hello everyone,
I would like to find the values of variables comparing coefficients in equation. Let's have a look at an easy example.
x^2 + 2*x + 5 = (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
May someone help me with finding 'a' and 'b' value?
Thanks

回答 (1 件)

Paul
Paul 2024 年 4 月 26 日
syms x a b
eqn = x^2 + 2*x + 5 == (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
eqn = 
cleft = coeffs(lhs(eqn),x,'all')
cleft = 
cright = coeffs(rhs(eqn),x,'all')
cright = 
sol = solve(cleft == cright,[a b])
sol = struct with fields:
a: 1 b: -3
Verify
isAlways(subs(eqn,sol))
ans = logical
1
  1 件のコメント
Jakub
Jakub 2024 年 4 月 28 日
Thank you so much!

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by