Running Simulink in steps and in Real Time.
5 次查看(过去 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
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Model, Block, and Port Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!