Contenuto principale

blocksAffectedByParameter

R2026b

Class: SLSlicerAPI.ParameterDependence
Namespace: SLSlicerAPI

Find Simulink blocks affected by parameter

Syntax

[affectedBlocks,slicerObj] = blocksAffectedByParameter(pd,varUsage)
[affectedBlocks,slicerObj] = blocksAffectedByParameter(pd,varusage,BlockType=blocktypename)

Description

[affectedBlocks,slicerObj] = blocksAffectedByParameter(pd,varUsage) returns a list of the blocks that are affected by the specified parameter varUsage, and the Model Slicer object used in the analysis.

[affectedBlocks,slicerObj] = blocksAffectedByParameter(pd,varusage,BlockType=blocktypename) returns affected blocks of the specified block type.

Input Arguments

expand all

Parameter dependence object, specified as a SLSlicerAPI.ParameterDependence object. The parameter dependence object determines the dependency between parameters and the Simulink model.

Parameters to query that affect the Simulink blocks in the model, specified as a Simulink.VariableUsage object, which stores information about where a variable is used in a model.

Name of block type to search, specified as a string or character vector. Only blocks of the specified type are searched for whether they use the specified parameter.

Example:

Output Arguments

expand all

Blocks affected by the parameter, returned as an array of block handles.

Model Slicer object used during the analysis, returned as an SLSlicerAPI.SLSlicer object.

Examples

expand all

% Open example and model
openExample("simulinktest/TestHarnessCallbackExample")
model = "RollAutopilotMdlRef";
open_system(model)

% Create a ParameterDependence object 
pd = SLSlicerAPI.ParameterDependence(model);

% Specify the parameter to query
varusage = Simulink.VariableUsage("rateLim",...
   "AttitudeControllerAutopilotMdlRef");

% Get all blocks affected by the parameter
[affectedBlocks,slicerObj] = ...
   blocksAffectedByParameter(pd,varusage);
names = get_param(affectedBlocks,"Name")
% Open example and model
openExample("simulinktest/TestHarnessCallbackExample")
model = "RollAutopilotMdlRef"
open_system(model)

% Create a ParameterDependence object 
pd = SLSlicerAPI.ParameterDependence(model);

% Specify the parameter to query
varusage = Simulink.VariableUsage("rateLim","AttitudeControllerAutopilotMdlRef");

% Get only Outport blocks affected by the parameter
[affectedOutports,slicerObj] = blocksAffectedByParameter(pd,varusage,BlockType="Outport");
names = get_param(affectedOutports,"Name")

Version History

Introduced in R2021b