array of symbolic variables which are function of time
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jai Tushar
el 25 de Oct. de 2017
Editada: Juraj Lieskovský
el 4 de Mzo. de 2021
p = sym('p', [m 1]);
the above code gives me an array of symbolic variables, where m is the size of the matrix. However i want to create an array of symbolic variables which are function of time i.e. p1(t),p2(t),.... .
0 comentarios
Respuesta aceptada
Walter Roberson
el 26 de Oct. de 2017
There is no facility to do this. You will need to loop (or equivalent). For example in R2017b or later,
p = arrayfun(@(N) str2sym(sprintf('p%d(t)',N)), 1:5).'
3 comentarios
Walter Roberson
el 26 de Oct. de 2017
ptemp = arrayfun(@(N) sym(sprintf('p%d(t)',N)), (1:m).', 'uniform', 0);
p = vertcat(ptemp{:});
You might get m warnings along the line of
Warning: Support of character vectors that are not valid variable names or define a number will be removed in a future release. To create symbolic
expressions, first create symbolic variables and then use operations on them.
Más respuestas (2)
Juraj Lieskovský
el 4 de Mzo. de 2021
Editada: Juraj Lieskovský
el 4 de Mzo. de 2021
Simple solution (using R2020b)
syms t
syms p(t) [m,1]
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!