Main Content


Specify parameter values for simulation configured using Simulink.SimulationInput object



simIn = setModelParameter(simIn,Name,Value) sets configuration parameter values on the Simulink.SimulationInput object simIn according to one or more name-value arguments.

You can use the setModelParameter function to configure the value for any model configuration parameter on a Simulink.SimulationInput object by passing the parameter name and value as a name-value argument.

Use getModelParameter('ParameterName') to get the value of a configuration parameter. Use removeModelParameter('ParameterName') to remove a configuration parameter from the Simulink.SimulationInput object.


collapse all

Configure model parameter values for a simulation using a Simulink.SimulationInput object.

Open the model.


Create a SimulationInput object for the model.

mdl = "sldemo_househeat";
simIn = Simulink.SimulationInput(mdl);

Specify a simulation timeout of 5 seconds then specify the start and stop time for the simulation.

simIn = setModelParameter(simIn,"Timeout",5);
simIn = setModelParameter(simIn,"StartTime","1","StopTime","4");

Simulate the model.

out = sim(simIn);

Input Arguments

collapse all

Simulation inputs and configuration, specified as a Simulink.SimulationInput object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: simIn = setModelParameter(simIn,"StopTime","100") configures a Simulink.SimulationInput object with a simulation stop time of 100.

In addition to the name-value arguments listed in this page, you can specify the value for any model configuration parameter as a name-value argument.

Option to disable rebuilding rapid accelerator target, specified as 'on' or 'off'. When you specify this argument as 'on', changes that require rebuilding the rapid accelerator target are ignored. When you use this option, modify only options that do not require rebuilding the rapid accelerator target.

Example: simIn = setModelParameter(simIn,"RapidAcceleratorUpToDateCheck","off") configures a Simulink.SimulationInput object to disable rebuilding the rapid accelerator target.

Data Types: char | string

Maximum simulation run time, specified as a positive scalar. Specify the time, in seconds, to allow the simulation to run. If the simulation runs for longer than the value you specify, the software issues a warning and stops the simulation. For example, if you specify TimeOut as 30, the software stops the simulation and issues a warning if computing simulation results takes more than 30 seconds.

The TimeOut parameter specifies a limit on the amount of clock time for a simulation to run. To specify the maximum time value to simulate, use the Stop time parameter.

Example: simIn = setModelParameter(simIn,"TimeOut",60) configures a Simulink.SimulationInput object with a maximum simulation run time of 60 seconds.

Data Types: char | string

Output Arguments

collapse all

Simulation configuration with model parameters added, returned as a Simulink.SimulationInput object.

Version History

Introduced in R2017a