simulation
Control simulation execution and tune variable, block parameter, and model parameter values
Since R2024a
Description
The Simulation
object represents a simulation of a model and
provides an interface to control the simulation. The Simulation
object
supports all simulation modes, including rapid accelerator, and deployment with Simulink®
Compiler™. Simulation execution does not block the MATLAB® command prompt except when you advance the simulation by calling the step
function.
You can use a Simulation
object to:
Initialize, start, and stop simulations.
Pause and step through simulations.
Tune variable, block parameter, and model parameter values before and during simulations.
Build custom apps to interact with simulations by using App Designer.
For more information about building apps to interact with simulations, see Create App for Simulink Model.
While you can programmatically interact with simulations you run using
Simulation
objects:
You cannot interact with the model or simulation associated with a
Simulation
object using the Simulink Editor while the simulation has a status other thaninactive
.Modifications that are never saved when you save a model, such as breakpoints and port value labels, do not apply to simulations run using the
Simulation
object.
By controlling simulation execution programmatically, you can integrate the systems and algorithms implemented in Simulink models into MATLAB scripts. For example, if you step to a point in the middle of a simulation, you can use MATLAB code to analyze the simulation results up to that point to determine whether to modify parameter values, the new value for a parameter, or how far to advance the simulation before analyzing the results again.
Creation
Description
s = simulation(
creates the
simin
)Simulation
object s
and sets property values
according to the corresponding property values of the Simulink.SimulationInput
object simin
.
Properties of the Simulink.SimulationInput
object that do not have a
corresponding property on the Simulation
object are not applied to the
Simulation
object. For example, the Simulation
object
does not support or have property values for any of the callback functions you can specify
on a SimulationInput
object, including the callback functions, such as
the external inputs callback function, that are available with Simulink
Compiler.