Solve symbolic equation by comparing coefficients
12 views (last 30 days)
Show older comments
Jörn Froböse
on 9 Feb 2022
Commented: Jörn Froböse
on 17 Feb 2022
I have an equation like this:
, which I need to rearrange to this form:
.


Obviously, the above holds true
for
and
. However, I would like to do this automatically. How can d and e be found using Matlabs Symbolic Toolbox?



The following approach won't help, since the system isn't well defined.
syms a b c d e f x y z
eq = a*x + y*(b + c*z)==0;
target = x + y*(d + e*z)==0;
solve([eq target],[d e])
Any help would be appreciated!
Accepted Answer
Prachi Kulkarni
on 15 Feb 2022
Edited: Prachi Kulkarni
on 15 Feb 2022
Hi,
For a given example expression of the form a*x + y*(b + c*x), you can get the coefficients d and e of the reduced forms as follows.
syms x y z
eq = 2*x + y*(3 + 4*z); % input equation
[d,e] = reducedCoefficients(eq);
function [d,e] = reducedCoefficients(eq)
coef = coeffs(eq);
b = coef(1);
c = coef(2);
a = coef(3);
d = double(b/a);
e = double(c/a);
end
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!