Convert a symbolic expresion to a vector

convert a symbolic expression to a vector with length of the number of terms of the expression
235.0 次下载
更新时间 2013/9/13

查看许可证

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]

引用格式

Luis Erasmo Miranda (2024). Convert a symbolic expresion to a vector (https://www.mathworks.com/matlabcentral/fileexchange/43479-convert-a-symbolic-expresion-to-a-vector), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2013a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0