Define a symbolic variable and then calculate it later

4 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2017-12-7
"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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by