eqn = 
Comparing coefficients and solving equation
Afficher commentaires plus anciens
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
Réponses (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 commentaire
Jakub
le 28 Avr 2024
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!