| Simulink® | ![]() |
Specify simulation options for simulations run via sim command
options = simset(param, value, ...); options = simset(old_opstruct, param, value, ...); options = simset(old_opstruct, new_opstruct); simset
The simset command creates and returns the structure required by the options argument of the sim command. The structure specifies the simulation parameter values to be used for the simulation run initiated by the sim command.
The block diagram parameter values in an options structure created by simset affect simulation only when the sim command executes with that options structure as an argument. After the simulation terminates, the values shown for block diagram parameters in the Configuration Parameters dialog box remain unchanged. The options structure persists and can be reused, perhaps after changing some of its values.
Note Use the set_param command to change a corresponding block diagram configuration parameter. |
You can enter the values of the parameters as paired arguments of the simset command, e.g., 'Debug', 'on'. You need enter only as many leading characters as are necessary to identify a parameter. The structure contains default values for parameters that you do not specify.
options = simset(param, value, ...) returns an options structure containing the specified values for the specified parameters and default values for unspecified parameters.
options = simset(old_opstruct, param, value, ...) modifies the specified parameters in old_opstruct, an existing structure. You can use this form of the command to override the values of simulation parameters specified by the model to be simulated. To do this, use the simget command to get the settings specified by the model and pass the settings to simset along with the parameters that you want to override.
options = simset(old_opstruct, new_opstruct) combines two existing options structures, old_opstruct and new_opstruct, into options. Any properties defined in new_opstruct overwrite the same properties defined in old_opstruct.
simset with no input arguments displays all parameter names and values that the simset command can specify
If a parameter is set more than once within a call to the simset command, the last specified value is used. For example:
simset('MaxStep', 0.01, 'MaxStep', 0.02) assigns the final value of 0.02 to the MaxStep parameter.
AbsTol positive scalar {1e-6}Absolute error tolerance. This scalar applies to all elements of the state vector. AbsTol applies only to the variable-step solvers.
Debug 'on' | {'off'} | cmdsDebug. Starts the simulation in debug mode (see Starting the Debugger in Using Simulink® for more information). The value of this option can be a cell array of commands to be sent to the debugger after it starts, e.g.,
opts = simset('debug', ...
{'strace 4', ...
'diary solvertrace.txt', ...
'cont', ...
'diary off', ...
'cont'})
sim('vdp',[], opts);
Decimation positive integer {1}Decimation for output variables. Decimation factor applied to the return variables t, x, and y. A decimation factor of 1 returns every data logging time point, a decimation factor of 2 returns every other data logging time point, etc.
DstWorkspace base | {current} | parentWhere to assign variables. Specifies the workspace in which to assign any variables defined as return variables or as output variables on the To Workspace block. See Superseding the Base Workspace for details.
ExtrapolationOrder 1 | 2 | 3 | {4}ode14x extrapolation order. Specifies extrapolation order of the ode14x implicit fixed-step solver.
FinalStateName string {''}Name of final states variable. This property specifies the name of a variable in which Simulink® software saves the model's states at the end of the simulation.
FixedStep positive scalar
Fixed step size. This property applies only to the fixed-step solvers. If the model contains discrete components, the default is the fundamental sample time; otherwise, the default is one-fiftieth of the simulation interval.
InitialState vector {[]}Initial continuous and discrete states. The initial state vector consists of the continuous states (if any) followed by the discrete states (if any). InitialState supersedes the initial states specified in the model. The default, an empty matrix, causes the initial state values specified in the model to be used. The initial state values can be specified using either an array, structure, or structure-with-time format. See Importing and Exporting States for more information.
InitialStep positive scalar {auto}Suggested initial step size. This property applies only to the variable-step solvers. The solvers try a step size of InitialStep first. By default, the solvers determine an initial step size automatically.
MaxOrder 1 | 2 | 3 | 4 | {5}Maximum order of ode15s. This property applies only to ode15s.
MaxDataPoints nonnegative integer {0}Limit number of output data points. This property limits the number of data points returned in t, x, and y to the last MaxDataPoints data logging time points. If specified as 0, the default, no limit is imposed.
MaxStep positive scalar {auto}Upper bound on the step size. This property applies only to the variable-step solvers and defaults to one-fiftieth of the simulation interval.
MinStep [positive scalar, nonnegative integer] {auto}Lower bound on the step size. This property applies only to the variable-step solvers and defaults to one-fiftieth of the simulation interval.
NumberNewtonIterations positive integer {1}Number of Newton iterations. Specifies number of Newton's Method iterations to be performed by the ode14x implicit fixed-step solver.
OutputPoints {specified} | allDetermine output points. When set to specified, the solver produces outputs t, x, and y only at the times specified in timespan. When set to all, t, x, and y also include the time steps taken by the solver.
OutputVariables {txy} | tx | ty | xy | t | x | ySet output variables. If 't', 'x', or 'y' is missing from the property string, the solver produces an empty matrix in the corresponding output t, x, or y.
Refine positive integer {1}Output refine factor. This property increases the number of output points by the specified factor, producing smoother output. Refine applies only to the variable-step solvers. It is ignored if output times are specified.
RelTol positive scalar {1e-3}Relative error tolerance. This property applies to all elements of the state vector. The estimated error in each integration step satisfies
e(i) <= max(RelTol*abs(x(i)),AbsTol(i))
This property applies only to the variable-step solvers and defaults to 1e-3, which corresponds to accuracy within 0.1%.
Solver VariableStepDiscrete |
ode45 | ode23 | ode113 | ode15s | ode23s |
FixedStepDiscrete |
ode5 | ode4 | ode3 | ode2 | ode1Method to advance time. This property specifies the solver that is used to advance time.
SaveFormat {'Array'} | 'Structure' | 'StructureWithTime'How to save output to workspace. Specifies format for exporting model states and root-level outputs to the MATLAB® workspace. See Exporting Data to the MATLAB® Workspace for more information.
SrcWorkspace {base} | current | parentWhere to evaluate expressions. This property specifies the workspace in which to evaluate MATLAB expressions defined in the model. See Superseding the Base Workspace for details.
Trace 'minstep', 'siminfo', 'compile' {''}Tracing facilities. This property enables simulation tracing facilities (specify one or more as a comma-separated list):
The 'minstep' trace flag specifies that simulation stops when the solution changes so abruptly that the variable-step solvers cannot take a step and satisfy the error tolerances. By default, Simulink software issues a warning message and continues the simulation.
The 'siminfo' trace flag provides a short summary of the simulation parameters in effect at the start of simulation.
The 'compile' trace flag displays the compilation phases of a block diagram model.
ZeroCross {on} | offEnable/disable location of zero crossings. This property applies only to the variable-step solvers. If set to off, variable-step solvers do not detect zero crossings for blocks having intrinsic zero-crossing detection. The solvers adjust their step sizes only to satisfy error tolerance.
SignalLogging {on} | offEnable/disable signal logging. This parameter enables signal logging for the model, overriding the Signal logging setting in the Configuration Parameters dialog box.
SignalLoggingName string
Specify signal logging name. This parameter specifies the name of the signal logging object used to record logged signal data in the MATLAB workspace. It overrides the Signal logging name setting in the Configuration Parameters dialog box.
You do not need to specify values for all block diagram parameters that simset accepts. In most cases, an unspecified parameter defaults to the block diagram value that is current when sim executes the model, but some options (such as MaxDataPoints) take on a different value. Additionally, not all parameters accepted by simset have an equivalent block diagram parameter.
For each parameter that simset accepts, the following table shows the equivalent block diagram parameter (if any) and the default value that applies if simset is called with no value specified for that simset parameter.
| Name of option specified to simset | Equivalent Block Diagram Parameter | Default Value when not specified to simset |
|---|---|---|
| AbsTol | AbsTol | Block diagram parameter |
| ConsecutiveZCsStepRelTol | ConsecutiveZCsStepRelTol | Block diagram parameter |
| Debug | Not available | Not available |
| Decimation | Decimation | Block diagram parameter |
| DstWorkspace | Not available | Not available |
| ExtrapolationOrder | ExtrapolationOrder | Block diagram parameter |
| FinalStateName | SaveFinalState is 'on' and FinalStateName is non-empty | Block diagram parameter |
| FixedStep | FixedStep | Block diagram parameter |
| InitialState | InitialState | Block diagram parameter |
| InitialStep | InitialStep | Block diagram parameter |
| MaxConsecutiveMinStep | MaxConsecutiveMinStep | Block diagram parameter |
| MaxConsecutiveZCs | MaxConsecutiveZCs | Block diagram parameter |
| MaxDataPoints | MaxDataPoints | All points (no limit) |
| MaxOrder | MaxOrder | Block diagram parameter |
| MaxStep | MaxStep | Block diagram parameter |
| MinStep | MinStep | Block diagram parameter |
| NumberNewtonIterations | NumberNewtonIterations | Block diagram parameter |
| OutputPoints | Not available | Not available |
| OutputVariables | Not available | Not available |
| Refine | Refine | Block diagram parameter |
| RelTol | RelTol | Block diagram parameter |
| SaveFormat | SaveFormat | Array |
| SignalLogging | SignalLogging | Block diagram parameter |
| SignalLoggingName | SignalLoggingName | Block diagram parameter |
| Solver | Solver | Block diagram parameter |
| SrcWorkspace | Not available | Not available |
| TimeOut | Not available | Not available |
| Trace | Not available | Not available |
| ZeroCross is 'on' | ZeroCrossControl is enable all | Block diagram parameter |
| ZeroCross is 'off' | ZeroCrossControl is disable all | Block diagram parameter |
This command creates an options structure called myopts that defines values for the MaxDataPoints and Refine parameters, using default values for other parameters.
myopts = simset('MaxDataPoints', 100, 'Refine', 2);
This command simulates the vdp model for 10 seconds and uses the parameters defined in myopts.
[t,x,y] = sim('vdp', 10, myopts);
The following command overrides the signal logging setting specified by the vdp model.
sim('vdp', 10, simset(simget('vdp'), 'SignalLogging', 'on'))![]() | simplot | simulink | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |