Thread Subject: Controlling Execution of Simulink

Subject: Controlling Execution of Simulink

From: Dave Lawson

Date: 7 Apr, 2008 20:40:19

Message: 1 of 1

  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?

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com