Define a symbolic variable and then calculate it later
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hello forum, I would build something like this:
my_input = 2+0.5*t;
with variable t not already defined. Then, in the same code, I would define the t vector and then re-calculate my_input with the proper values of t. I need it because in this code, the user can only modify the first section. If I declare the time variable earlier, there is the risk to be modified.
Example of what I would realize (but with syms it does not work):
syms t
my_input = 2+0.5*t; % t is a sort of symbolic variable
t = linspace(0,100,1000); % now t is a real variable
my_new_input = my_input; % but now calculated with real t values
1 comentario
Stephen23
el 7 de Dic. de 2017
"I need it because in this code, the user can only modify the first section. If I declare the time variable earlier, there is the risk to be modified."
That is not a very good reason to use symbolic math. Just design your code better by splitting it into some functions that are called by the user.
Respuestas (0)
Ver también
Categorías
Más información sobre Symbolic Math Toolbox 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!