sim
Simulate a万博1manbetxmodel
Syntax
Description
A Simulink®model represents a dynamic system. Simulating a model lets you understand the behavior of the system as a function of simulated time. Thesim
command uses the specified model and applies the arguments to the model. At the end of the simulation, thesim
command reverts any arguments that it applied.
simulates the specified model using existing model configuration parameters, and returns the result as asimOut
= sim(model
)Simulink.SimulationOutput
object (single-output format).
In theData Import/Exportpane of theConfiguration Parametersdialog box,Single simulation outputis selected by default. If theSingle simulation outputis not selected, the simulation results are returned as a time vector.
To return simulation results using the backward-compatible format (time vector), seeBackward-Compatible Syntax.
simulates the specified model using parameter name-value pairs.simOut
= sim(model
,Name,Value
)
simulates the model using the inputs specified in thesimOut
= sim(simIn
)Simulink.SimulationInput
objectsimIn
. Thesim
command can be used with an array of模拟Input
objects to run multiple simulations in a series. IfsimIn
is an array ofSimulink.SimulationInput
objects, output is returned as an array ofSimulink.SimulationOutput
objects.
simulates the specified model using the parameter values specified in the structuresimOut
= sim(model
,ParameterStruct
)ParameterStruct
.
Examples
Input Arguments
Output Arguments
More About
Tips
Parameters specified using the
sim
command override the values defined in theModel Configuration Parametersdialog box. The software restores the original configuration values at the end of simulation.
In the case of a model with aModel块,应用于参数规范the top model.
When simulating a model with infinite stop time, to stop the simulation, you must pressCtrl+C.Ctrl+Cbreaks the simulation, and the simulation results are not saved in the MATLAB workspace.
To specify the time span for a simulation, you must specify the
StartTime
andStopTime
parameters.To log the model time, states, or outputs, use theData Import/Exportpane of the Model Configuration Parameters dialog box.
To log signals, either use aTo Workspaceblock such as theTo Workspaceblock or theScopeblock, or use Signal Logging. For more information, seeExport Signal Data Using Signal Logging.
To get a list of simulation parameters for the model
vdp
, in the MATLAB Command Window, enter:configSet = getActiveConfigSet('vdp') configSetNames = get_param(configSet, 'ObjectParameters')
This command lists several object parameters, including simulation parameters such as
'StopTime'
,'SaveTime'
,'SaveState'
,'SaveOutput'
, and'SignalLogging'
.