How to use Callbacks in SimEvents?

1 visualizzazione (ultimi 30 giorni)
Matthias Meißner
Matthias Meißner il 29 Nov 2017
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?

Risposte (1)

Teresa Hubscher-Younger
Teresa Hubscher-Younger il 30 Nov 2017
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

Categorie

Scopri di più su Discrete-Event Simulation in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by