eqn = 
Comparing coefficients and solving equation
Ältere Kommentare anzeigen
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
Antworten (1)
syms x a b
eqn = x^2 + 2*x + 5 == (b+4*a)*x^2 + (5*a+b)*x + (-b+2*a)
cleft = coeffs(lhs(eqn),x,'all')
cright = coeffs(rhs(eqn),x,'all')
sol = solve(cleft == cright,[a b])
Verify
isAlways(subs(eqn,sol))
1 Kommentar
Jakub
am 28 Apr. 2024
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!