Running Simulink in steps and in Real Time.

2 次查看(过去 30 天)
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

采纳的回答

Sebastian Castro
Sebastian Castro 2015-5-11
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 个评论
MRR
MRR 2015-5-12
编辑:MRR 2015-5-12
Sebastián. Thank your for your answer. That's exactly what I was looking for!
Regards,
-Mario

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Event Functions 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by