How to change variables in time in Simulink?

27 次查看(过去 30 天)
I have some processing (moving of wheelset). Wheelset has mass, it's variable and it's declaring in init.m file (for example M=1;)
Now I want that in this proccess mass of wheelset will be changed every 2 seconds. How to save the new value of mass to M variable from Simulink?

采纳的回答

Jarrod Rivituso
Jarrod Rivituso 2011-4-21
It sounds to me like you want the mass data to be a signal, and not a parameter that is defined by a workspace variable.
I think of Simulink as having data which are either signals or parameters:
  • Signal - value updates during simulation time
  • Parameter - value does not change unless user manually changes it
To get a mass that changed every two seconds, I would define the mass as an input signal derived from one of the Source blocks (Simulink -> Sources library) such as Inport, From Workspace, Signal Builder, etc.
  1 个评论
Evgheny
Evgheny 2011-4-21
I've made `Const Block` with M value and then `Fcn Block` with inputs of `M` and `time` and output of a new `M`. This new `M` I gave to all blocks I needed (early I haven't `M` in model - it was taken from workspace, but now it is signal)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by