setBlockParameter

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

Description

example

in = in.setBlockParameter('BlockPath','ParameterName','Value',...'BlockPathN''ParameterNameN','ValueN') sets the parameter on the block specified at BlockPath with the properties ParameterName and Value. You can use the setBlockParameter method to specify block parameters in model reference hierarchy. You can set multiple block parameters in a model using the same SimulationInput object. For more information on block parameter, see Block-Specific Parameters.

You can use getBlockParameter('BlockPath','ParameterName') method to get the value of block parameter and the removeBlockParameter('BlockPath','ParameterName') method to remove block parameter from the Simulink.SimulationInput object.

Examples

collapse all

This example modifies the block parameters of a model through the SimulationInput object.

Open the model

mdl = 'sldemo_househeat';
open_system(mdl);

Create a SimulationInput object 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 the SimulationInput object.

Open the model

mdl = 'vdp';
open_system(mdl);

Create a SimulationInput object for this model.

in = Simulink.SimulationInput(mdl);

Modify block parameter.

in = in.setBlockParameter('vdp/Mu','Gain','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 of ParameterName,Value arguments. ParameterName is the parameter name and Value is the corresponding value. ParameterName must 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 as Name1,Value1,...,NameN,ValueN. ParameterNameN,ValueN pairs follow the same syntax as set_param.

Example: 'Value', '350'

Introduced in R2017a