|
Hi! I'm new to the game here, and working on my first
project, and feel like I need some help to get over a
hump. In short, my difficulty revolves around swapping
controls between Simulink and my Matlab script.
I have a main loop that runs in my script file. Each
iteration through this loop, I want to run my simulation
through to completion (not quitting, though, just pausing
at the end!), extract some information from my simulation
and adjust certain parameters before returning to the top
of the loop.
I've dug a little bit, but it seems like execution isn't
exactly where I want it to be. Here is how I've been
trying to get it done:
load_system( 'elevator_model' );
for(...)
...
status = get_param( 'elevator_model',
'SimulationStatus' )
if ( strcmp( status, 'paused' ) == 1 )
set_param( 'elevator_model', 'SimulationCommand',
'continue' );
else %this is our first pass, and we have to start up
set_param( 'elevator_model', 'SimulationCommand',
'start' );
end
*SOMEHOW WAIT UNTIL SIMULATION HAS PAUSED AGAIN*
...
end
I've attempted putting a loop that sits until the
status is not 'running', but it seems to hang
indefinitely. I feel like I need something akin to a
sleep, that will pass control back to simulink. Anyone
have an idea how I could wait until the simulation has
paused in it's execution?
|