How to use Callbacks in SimEvents?

1 回表示 (過去 30 日間)
Matthias Meißner
Matthias Meißner 2017 年 11 月 29 日
回答済み: Teresa Hubscher-Younger 2017 年 11 月 30 日
I want to change the value of an attribute of an entity within the SimEvents Block Entity Generator. Background is that I want to change this attribute dependent on the simulation time. However, I did not find a way to get access to the appropriate Attribute because I am not able to find the correct name of these parameter to use the set_param function. Did someone knows a way to solve this problem?

回答 (1 件)

Teresa Hubscher-Younger
Teresa Hubscher-Younger 2017 年 11 月 30 日
Hi,
If you want entities generated at a certain simulation time to have a certain attribute, the best way to do that is within SimEvents, not to have Simulink to control it via callbacks. You can do this by having the Entity Generator call out to a Simulink Function on the Generate Event Action to check the time. This MATLAB Answers post talks about how to get current simulation time using Simulink blocks while the model is executing https://www.mathworks.com/matlabcentral/answers/57825-how-to-get-current-time-of-simulation-while-model-is-executing. You can put that in a Simulink Function and access that via MATLAB in an Event Action to determine which attribute should be assigned. Here is help on the Simulink Function block: https://www.mathworks.com/help/simulink/slref/simulinkfunction.html Here is an example with a Simulink Function: https://www.mathworks.com/help/simevents/examples/simulate-scheduler-of-a-multicore-control-system.html
Please let me know if this helps.
Thanks, Teresa

カテゴリ

Help Center および File ExchangeDiscrete-Event Simulation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by