Running Simulink in steps and in Real Time.
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi,
I have a GUI and a Simulink model running in background, in a similar way as this example does:
In addition I have set up a timer (a timer object) whose callback ('TimerFcn') is executed a defined period of time. Each time the callback is executed it takes some values from the simulink model, I simply use the sentence str2num(get(handles.curState,'string'), which takes the value that was passed from Simulink to the GUI. So, as you can see I only take values at predefined steps of time. I have two questions:
1- Is it possible to run Simulink in real time mode? I notice when simulating time "goes faster", and I do not want that. So far there is no hardware involved, everything is in simulation.
2- I am thinking in another approach. Instead of a continuous simulation (as the example I am based on does and as I am doing), I am wondering if it is possible to run a set of simulations, where the end conditions of the last simulation are the initial conditions of the next one, based on the period of time defined by the timer. Here is an example:
My timer has a period of 3 seconds. Then I run simulink for 3 seconds and take the output values, and so for. Is there any recommended approach to do this? I think something can be done by pausing and restarting the simulation.
Regards. -M
0 commentaires
Réponse acceptée
Sebastian Castro
le 11 Mai 2015
For your first question, there is a Real-Time Pacer block on the File Exchange which will slow your model down to "soft" real-time (that is, an approximation or "slowing down" to real-time).
For the second question, there is indeed a way to do that using what is known as SimState. As you asked, this lets you pause or stop a simulation, collect data, and then pick up from where you left off.
Hope this helps!
- Sebastian
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Model, Block, and Port Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!