From symbolic expression to vector
6 views (last 30 days)
Show older comments
Farid Salazar Wong
on 23 Jun 2015
Commented: Star Strider
on 23 Jun 2015
I have a symbolic expression in the form of a polynomial in several variables (e.g. 2*x*y*z - x*z - y*z - x*y + 1), is there any way I could get a vector out of this, I mean something like [2*x*y*z, - x*z, - y*z, - x*y, 1].
0 Comments
Accepted Answer
Star Strider
on 23 Jun 2015
Use the coeffs function and then get slightly creative:
syms x y z
f = 2*x*y*z - x*z - y*z - x*y + 1;
[cf,T] = coeffs(f);
V = cf .* T % Desired Output
V =
[ 2*x*y*z, -x*y, -x*z, -y*z, 1]
2 Comments
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!