Systematically pause Simulink model and continue from Matlab command line
18 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Thomas Marullo
el 2 de Jul. de 2013
Editada: Daniel Rutherford
el 11 de Mzo. de 2020
Is it possible to have Matlab start a Simulink model (fixed step, discrete) and after each sample step, the model pauses, allows Matlab to do some data handling from the model, then waits for Matlab to tell the model to resume the next sample step? I have a very specific application that requires some functions in Matlab but I want to use Simulink to handle most of the heavy lifting.
0 comentarios
Respuesta aceptada
Kaustubha Govind
el 2 de Jul. de 2013
What kind of data handling would you like to do in MATLAB? You might want to look at Access Block Data During Simulation, which lets you work your MATLAB code into the simulation process instead of artificially pausing/continuing.
3 comentarios
Kaustubha Govind
el 3 de Jul. de 2013
Thomas: The interface in the link I posted doesn't provide arbitrary access, but is indeed step-by-step - if you read the documentation, you will see that the mechanism involves attaching a PostOutputs callback to a specific block, so your function is called at every step that the block produces new outputs. It doesn't matter how long your code takes to execute - Simulink should wait until it's done.
Más respuestas (3)
Guru
el 3 de Jul. de 2013
Honestly, this is easier to do if you use MATLAB blocks within your Simulink to validate the results that you are looking for. However you can either use the Simulink Debugger commands from MATLAB to step through each individual block output based on sorted order, or you use:
set_param('model_name','SimulationCommand','pause') set_param('model_name','SimulationCommand','start') set_param('model_name','SimulationCommand','stop')
which are the command line functions that are equivalent to clicking the pause, play, stop buttons respectively.
0 comentarios
Guy Rouleau
el 2 de Jul. de 2013
In most cases where I have seen users asking to control the execution of a model from MATLAB code, the most appropriate solution was to include the MATLAB code inside the simulation and let simulink control the execution.
Whatever data you wan to extract from the model at every step should be available on a signal line. So you it should be possible to feed it to a block that you can code with MATLAB code (MATLAB Function block, MATLAB s-function, interpreted MATLAB Function block, etc.) The block will do your processing and it will be available as a signal to other blocks for the next step.
4 comentarios
Daniel Rutherford
el 11 de Mzo. de 2020
Editada: Daniel Rutherford
el 11 de Mzo. de 2020
So, if I have a legacy matlab simulation (lets say a seeker), and Bubba wants me to use state dynamics from a 3-DOF Simulink Simulation to provide kinematic information periodically for each seeker update dwell, I should trash my legacy, 2000 hour test matlab simulation, and throw it into the disfunctionality of simulink? I'd rather rewrite the 3DOF in a matlab script.
There needs to be a better effort by matlab to integrate simulink results into a matlab script.
Preferably, I'd like to use a simulink model like I use the call to an ode function.
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!