pause() Matlab to wait for Simulink in R2016a

4 views (last 30 days)
Hi,
I have a Matlab script that resumes a paused Simulink simulation and waits until it pauses again. (Simulink pauses by itself using an Assertion block.) The matlab code I use is
set_param(model,'SimulationCommand','continue');
while true
plantStatus = get_param(model,'SimulationStatus');
if strcmp(plantStatus,'running')
clc
display('waiting for Simulink to pause...')
pause(0.1) %give thread to simulink
elseif strcmp(plantStatus,'paused')
%display('paused by Simulink')
break
end
end
This worked fine on R2015b. On R2016a it seems as the 'while loop' is blocking Simulink from making progress in the simulation. This prevents it from reaching its pause time and therefore the Matlab loop runs forever.
To prevent Matlab from blocking Simulink, the 'pause(0.1)' statement worked before. Was its behavior changed in R2016a? Any ideas how I can fix this again?
Thanks!
  2 Comments
Felix Rey
Felix Rey on 21 Jun 2016
Maybe the pause() function was reimplemented to allow the new pause-simulation feature in R2016a. I am just writing this to get more attention to my question ;(
Andreas Goser
Andreas Goser on 21 Jun 2016
If this is an important topic for you and there is no response in this users help users forum, I suggest you contact Technical Support.

Sign in to comment.

Accepted Answer

Felix Rey
Felix Rey on 30 Sep 2016
I found the answer myself. I seems the problem is caused by the argument of the pause()-command. In my actual simulation (not the simple example above), the pause duration was just 500us, which worked with R2015b but not R2016a. Hence, increasing this duration to 1ms did the trick.

More Answers (0)

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!