I have two symbolic polynomials of the same order. One of them also has symbolic coefficients, and the other one numerical coefficients. I would like to assign values of the numerical ones to the symbolic ones. There is example in a body below.

1 view (last 30 days)
syms K0 K1 x;
f1=x^2 + K1*s +K0;
f2=x^2 + 3*s + 5;
i want to get K1=3 and K0=5.
Thanks, Janis

Answers (1)

Walter Roberson
Walter Roberson on 21 Dec 2012
coeffs(). Unfortunately MuPAD does not have Maple's coeff() which makes this kind of thing much easier.
Or....
K0coeff = subs(f2, x, 0);
K1coeff = subs(f1, {x, K0, s}, {0, K0coeff, 1});
However.... you did not declare "s" as a symbol but you seem to be using it as a symbol, and since you mentioned "polynomial" it seems strange that your polynomials appear to be in both x and s. Did you have a typo and mean the s to be x in both polynomial? If so then the procedure is slightly different:
K0coeff = subs(f2, x, 0);
K1coeff = subs((f2 - K0coeff)/x, x, 0);

Categories

Find more on Polynomials 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!