Tuning block parameters at every time step in a simulation

版本 1.0.0.1 (7.9 KB) 作者: Nishaat Vasi
Model which changes the parameter of a block with every time step – without using S-functions.
1.0K 次下载
更新时间 2016/9/1

查看许可证

I needed a simple model which could change the parameter of a block (say Gain block) with every time step – without using S-functions. There are numerous ways to do this. After trying out a couple of things, I came up with a simple model which demonstrates this.
Open the “updating_sim” model, and run the simulation. Open the scope and notice how the input Sine wave is multiplied by an increasing Gain amount at each time step (0.2s). The final value of Gain is 51 (since in 10s there will by 51 time steps).

Here I have used the "add_exec_event_listener" within my StartFcn model callback, which triggers a listener function called "update_param" whenever the event "PostOutputs" is hit for the block "updating_sim/Gain". Also note that the Gain value is reset to '0' for each simulation run using the InitFcn callback.

引用格式

Nishaat Vasi (2024). Tuning block parameters at every time step in a simulation (https://www.mathworks.com/matlabcentral/fileexchange/24935-tuning-block-parameters-at-every-time-step-in-a-simulation), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2009a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Simulation 的更多信息

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.0.0.1

Updated license

1.0.0.0