File Exchange

image thumbnail

Convert a symbolic expresion to a vector

version 1.0 (1.27 KB) by

convert a symbolic expression to a vector with length of the number of terms of the expression

0 Downloads

Updated

View License

Convert each expression to a vector with length of the number of terms of an expression:
for example:
syms x a b c
r= a*x^2+b*x+c-exp(x)
R=sym2vec(r);
results in:
R =
 [ c, -exp(x), b*x, a*x^2]

Limitations:
this is a rude way to solve the issue, the expression r always is expanded before assign to the vector
for example:
r = x*(a+b)+x
R=sym2vec(r)
you should have:
R=
   [ x*(a+b), x]
but instead, you have:
R =
   [ x, a*x, b*x]

Comments and Ratings (0)

MATLAB Release
MATLAB 8.1 (R2013a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video