This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Set model parameters to be used for a specific simulation through SimulationInput object, in


in = in.setModelParameter('ParameterName', 'Value', … 'ParemeterNameN', 'ValueN')



in = in.setModelParameter('ParameterName', 'Value', … 'ParemeterNameN', 'ValueN') sets a model parameter Name with a Value. You can add multiple model parameters to the model using the same SimulationInput object. For more information on model parameters, see Model Parameters.

You can use getModelParameter('ParameterName') method to get the value of model parameter and the removeModelParameter('ParameterName') method to remove model parameter from the Simulink.SimulationInput object


collapse all

This example modifies the model parameters of through the SimulationInput object

Open the model.

mdl = 'sldemo_househeat';

Create a SimulationInput object for this model.

in = Simulink.SimulationInput(mdl);

Specify a timeout of 5 seconds and modify model parameters, StartTime and StopTime

in = in.setModelParameter('Timeout',5);
in = in.setModelParameter('StartTime','1','StopTime','4');

Simulate the model.

out = sim(in)

Input Arguments

collapse all

Specify optional comma-separated pairs of ParameterName,Value arguments. ParameterName is the parameter name and Value is the corresponding value. ParameterName must appear inside single quotes (' '). Model parameter values are typically specified as character vectors. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN. ParameterNameN,ValueN pairs follow the same syntax as set_param.

Example: 'StartTime','1'

Introduced in R2017a