Main Content

setModelParameter

Set model parameters to be used for a specific simulation throughSimulationInputobject,in

Description

example

in = in.setModelParameter('ParameterName', 'Value', … 'ParameterNameN', 'ValueN')sets a model parameterNamewith aValue. You can add multiple model parameters to the model using the sameSimulationInputobject.

You can usegetModelParameter('ParameterName')method to get the value of model parameter and theremoveModelParameter('ParameterName')method to remove model parameter from theSimulink.SimulationInputobject.

Examples

collapse all

This example modifies the model parameters of through theSimulationInputobject

Open the model.

mdl ='sldemo_househeat'; open_system(mdl);

创建一个SimulationInputobject for this model.

in = Simulink.SimulationInput(mdl);

Specify a timeout of 5 seconds and modify model parameters,StartTimeandStopTime

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 ofParameterName,Valuearguments.ParameterNameis the parameter name andValueis the corresponding value.ParameterNamemust 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 asName1,Value1,...,NameN,ValueN.ParameterNameN,ValueNpairs follow the same syntax asset_param.

Example:'StartTime','1'

版本历史

Introduced in R2017a