MATLAB Answers

0

How to use Callbacks in SimEvents?

Asked by Matthias Meißner on 29 Nov 2017
Latest activity Answered by Teresa Hubscher-Younger on 30 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?

  0 Comments

Sign in to comment.

1 Answer

Answer by Teresa Hubscher-Younger on 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

  0 Comments

Sign in to comment.