How to `subs` with both scalar variable and arrays?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
wei zhang
el 22 de Jun. de 2020
Respondida: madhan ravi
el 22 de Jun. de 2020
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 comentarios
Respuesta aceptada
madhan ravi
el 22 de Jun. de 2020
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Assumptions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!