setModelParameter

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

Description

example

in = in.setModelParameter('ParameterName', 'Value', … 'ParameterNameN', 'ValueN') sets a model parameter Name with a Value. You can add multiple model parameters to the model using the same SimulationInput object.

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

Examples

collapse all

This example modifies the model parameters of through the SimulationInput object

Open the model.

mdl = 'sldemo_househeat';
open_system(mdl);

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