MATLAB Answers

Running Simulink in steps and in Real Time.

2 views (last 30 days)
MRR
MRR on 11 May 2015
Edited: MRR on 12 May 2015
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

Accepted Answer

Sebastian Castro
Sebastian Castro on 11 May 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
  1 Comment
MRR
MRR on 12 May 2015
Sebastián. Thank your for your answer. That's exactly what I was looking for!
Regards,
-Mario

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!