How to create symbolic polynomial with specific vector of coefficients of symbolic variables in MatLab? - poly2sym -- MatLab
How to create symbolic polynomial with specific vector of coefficients of symbolic variables in MatLab? - poly2sym -- MatLab
How to create symbolic polynomial with specific vector of coefficients of symbolic variables in MatLab?
[Ans]
poly2sym
[description]
sym coeefficients -> poly
more details on:
code:
clear
clc
syms a b c d
p = poly2sym([a, b, c, d])
fprintf("1\n");
p = poly2sym(sym([1/2, -1/3, 1/4]))
fprintf("2\n");
p = poly2sym([0.75, -0.5, 0.25])
fprintf("3\n");
syms a b c d t
p = poly2sym([a, b, c, d], t)
fprintf("4\n");
p1 = subs(p, t, t^2 + 1)
p2 = subs(p, t, exp(t))
fprintf("5\n");
result:
p =
a*x^3 + b*x^2 + c*x + d
1
p =
x^2/2 - x/3 + 1/4
2
p =
(3*x^2)/4 - x/2 + 1/4
3
p =
a*t^3 + b*t^2 + c*t + d
4
p1 =
d + a*(t^2 + 1)^3 + b*(t^2 + 1)^2 + c*(t^2 + 1)
p2 =
d + c*exp(t) + a*exp(3*t) + b*exp(2*t)
5
Comments
Post a Comment