Main Content

setBlockParameter

Set block parameter values on Simulink.SimulationInput object

Description

example

simIn = setBlockParameter(simIn,blkPath,blkParam,paramVal) sets the block parameter value on the Simulink.SimulationInput object simIn.

You can use the setBlockParameter function to specify block parameters for blocks throughout a model reference hierarchy. You can set multiple block parameters on a Simulink.SimulationInput object.

You can use getBlockParameter(blkPath,blkParam) to get the value of a block parameter and removeBlockParameter(blkPath,blkParam) to remove a block parameter from the Simulink.SimulationInput object.

Examples

collapse all

Modify a block parameter for a simulation using a Simulink.SimulationInput object.

Open the model

openExample("simulink_general/sldemo_househeatExample");

Create a SimulationInput object for this model.

mdl = "sldemo_househeat";
simIn = Simulink.SimulationInput(mdl);

Modify block parameter value.

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

Simulate the model.

out = sim(simIn);

Modify multiple block parameter values for a simulation using a Simulink.SimulationInput object.

Open the model

mdl = 'vdp';
open_system(mdl);

Create a SimulationInput object for this model.

simIn = Simulink.SimulationInput(mdl);

Modify the Gain parameter value for the Mu block and the position of the Product block.

simIn = setBlockParameter(simIn,'vdp/Mu','Gain','40',...,
    'vdp/Product','Position',[50 100 110 120]);

Simulate the model.

out = sim(simIn);

Input Arguments

collapse all

Simulation inputs and configuration, specified as a Simulink.SimulationInput object.

Path of the block, specified as a string or a character vector.

Example: 'sldemo_househeat/Set Point'

Block parameter name, specified as a string or a character vector.

Example: 'Value', '350'

Block parameter value, typically specified as a character vector.

Example: 'Value', '350'

Output Arguments

collapse all

Simulation configuration with block parameter values added, returned as a Simulink.SimulationInput object.

Version History

Introduced in R2017a