Code covered by the BSD License  

Highlights from
Convert a symbolic expresion to a vector

Be the first to rate this file! 10 Downloads (last 30 days) File Size: 1.27 KB File ID: #43479

Convert a symbolic expresion to a vector

by

 

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

| Watch this File

File Information
Description

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]

Required Products Symbolic Math Toolbox
MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.

Contact us