How to `subs` with both scalar variable and arrays?
1 次查看(过去 30 天)
显示 更早的评论
I am evaluating some expression with subs. I need to input a scalar variable and an array. But it always give errors as I substitute them in one command as below.
e.g.
syms x
syms t [1 3]
g = x+t1+t2;
result = subs(g,{x,t},{1,[1,2,3]});
This is a mini case for my problem. How to solve this error? Must I subs the variables in several independent steps?
0 个评论
采纳的回答
madhan ravi
2020-6-22
syms x
syms t [1 3]
g = x+t1+t2;
t_vars = num2cell(t);
t_vals = num2cell(1:3);
result = subs(g,{x,t_vars{:}},{1,t_vals{:}})
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!