How can I create a multistep function with variable number of steps in simulink?

40 ビュー (過去 30 日間)
Evan Tsiklidis
Evan Tsiklidis 2018 年 5 月 30 日
回答済み: Sviatoslav Klos 2018 年 12 月 5 日
I am running a simulation in simulink that requires me to change the value of a constant block during the simulation. If I have an array of of all of the values i want to use, how can I have it change from value to value based on the time of the simulation ? I have tried using the clock and floor function, this will return an integer that I can use to reference the element of the array . However, the index of the array in the constant block does not appear to be able to change. Can anyone help with this? See attached MATLAB code for a visual description of the problem.

回答 (2 件)

Nikhil Negi
Nikhil Negi 2018 年 5 月 31 日
Hello Evan,
You can use a selector block to select different elements of a vector. I've modified your example you can see it and also read about selector block to modify it according to your needs.

Sviatoslav Klos
Sviatoslav Klos 2018 年 12 月 5 日
I can suggest to use some manualization of running simulink.
You can create some kind of 'for' or 'while' cycle with command
set_param('vdp','SimulationCommand','stepforward')
% update constant block variable
cont1=array(1,i);
set_param('modelName','SimulationCommand','update')
end
This may solve your issue.
You may read more about commands here - https://www.mathworks.com/help/simulink/ug/using-the-sim-command.html

カテゴリ

Help Center および File ExchangeSimulink Functions についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by