how to use run-time object in simulink model?

7 visualizzazioni (ultimi 30 giorni)
Yandy Ma
Yandy Ma il 25 Lug 2017
Commentato: Yandy Ma il 25 Lug 2017
I would like to control my simulink model from a matlab script by using set_param. And I would like to have some pause time in between. If I use pause(), the pausing time will be a real time. However, I would like to pause it according to simulation. For example: I would to set_param at simulation time = 5. And someone recommend me to use a 'run-time object'. And I have no idea how can I use it. Can someone give me an example of using the run-time object?

Risposte (1)

jpai
jpai il 25 Lug 2017
By the looks of it you want to be able to pause a running simulation through a command. It may not be necessary for you to use a run-time object at all in order to achieve the operation that you desire. As a matter of fact, you can continue using set_param to control your simulation.
For your specific case, you can use:
set_param('mymodel','SimulationCommand','pause')
This will pause the currently running model mymodel (or whatever your running model's name is).
To continue running the model, you can simply use:
set_param('mymodel', 'SimulationCommand','continue')
As the third parameter suggests, this will resume the paused model.
For more information on SimulationCommands, please refer to the following link:
https://www.mathworks.com/help/releases/R2017a/simulink/slref/model-parameters.html (Search for "SimulationCommand" in the Model Parameters table)
Hope this helps!
  1 Commento
Yandy Ma
Yandy Ma il 25 Lug 2017
Thanks for answering my question! However, I would like to keep the model running, while using the set_param for every 5sec of simulation time. Coz I would like to observe the transience of the model if I change the parameter within the model for every few seconds of simulation time while the model should be kept running. Do you have any recommendation for me? Really thanks a lot!

Accedi per commentare.

Categorie

Scopri di più su Programmatic Model Editing 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