Main Content

setBlockParameter

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

Description

example

in = in.setBlockParameter('BlockPath','ParameterName','Value',...'BlockPathN''ParameterNameN','ValueN')sets the parameter on the block specified atBlockPathwith the propertiesParameterNameandValue. You can use thesetBlockParametermethod to specify block parameters in model reference hierarchy. You can set multiple block parameters in a model using the sameSimulationInputobject.

You can usegetBlockParameter('BlockPath','ParameterName')method to get the value of block parameter and theremoveBlockParameter('BlockPath','ParameterName')method to remove block parameter from theSimulink.SimulationInputobject.

Examples

collapse all

This example modifies the block parameters of a model through theSimulationInputobject.

Open the model

mdl ='sldemo_househeat'; open_system(mdl);

创建一个SimulationInputobject for this model.

in = Simulink.SimulationInput(mdl);

Modify block parameter.

in = in.setBlockParameter('sldemo_househeat/Set Point','Value','300');

Simulate the model.

out = sim(in)

This example modifies the block parameters of a model through theSimulationInputobject.

Open the model

mdl ='vdp'; open_system(mdl);

创建一个SimulationInputobject for this model.

in = Simulink.SimulationInput(mdl);

Modify block parameter.

in = in.setBlockParameter('vdp/Mu',“获得”,'40','vdp/Product','Position',[50 100 110 120]);

Simulate the model.

out = sim(in)

Input Arguments

collapse all

BlockPath is the path of the block for which the parameter is changed

Example:'sldemo_househeat/Set Point'

Specify optional comma-separated pairs ofParameterName,Valuearguments.ParameterNameis the parameter name andValueis the corresponding value.ParameterNamemust appear inside single quotes (' '). Block 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:'Value','350'

Version History

Introduced in R2017a