How can I assign a symbolic expression to symbolic an element of an array
4 次查看(过去 30 天)
显示 更早的评论
syms x y u v w
var = [x,y];
sol = [u+w,v-w]
I just started learning MATLAB and I hope someone out there can help me.
How can I assign the symbolic expressions of sol to the elements of var, so that x and y have the values
x = u+w;
y = v-w;
Thanks
0 个评论
采纳的回答
Walter Roberson
2018-9-28
We recommend against that.
I suspect you should consider using the single output version of solve(): when there is more than one variable being solved for, it returns a struct or struct array whose fields are named after the variables. You can use that struct as the second input of subs()
sol = solve(....)
subs(EXPRESSION, sol)
When you compute a value and think you want to assign it to a a dynamic variable name, then the large majority of the time it is better to subs() instead.
更多回答(1 个)
madhan ravi
2018-9-28
编辑:madhan ravi
2018-9-28
syms x y u v w
var = [x,y];
sol = [u+w,v-w];
disp(var==sol)
5 个评论
Walter Roberson
2018-9-28
For more information about how symbolic variables work, see https://www.mathworks.com/matlabcentral/answers/421188-trouble-converting-syms-for-plotting-plots-not-accepting-values-as-input#comment_615409
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!