Simulink.findBlocksOfType

Find specified type of block in Simulink models

Description

example

bl = Simulink.findBlocksOfType(sys,type) returns handles to all blocks of the specified type in the model or subsystem sys.

example

bl = Simulink.findBlocksOfType(sys,type,options) matches the criteria specified by a FindOptions object.

bl = Simulink.findBlocksOfType(sys,type,Param1,Value1,...,ParamN,ValueN) finds blocks whose parameters have the specified values.

bl = Simulink.findBlocksofType(sys,type,Param1,Value1,...,ParamN,ValueN,options) finds blocks whose parameters have the specified values and that match the criteria specified by a FindOptions object.

Examples

collapse all

Find all blocks of type Gain in the model vdp.

load_system('vdp');
Simulink.findBlocksOfType('vdp','Gain')
ans =

    7.0001

To return block names instead of handles, use getfullname.

getfullname(Simulink.findBlocksOfType('vdp','Gain'))
ans =

    'vdp/Mu'

Load the model sldemo_clutch. Then, create a FindOptions object and use it to constrain the search of GoTo blocks in the model to the Unlocked system.

load_system('sldemo_clutch');
f = Simulink.FindOptions('SearchDepth',1);
bl = Simulink.findBlocksOfType('sldemo_clutch/Unlocked','Goto',f)
bl =

  166.0001
  167.0001

Input Arguments

collapse all

Model or subsystem to find blocks in, specified as a character vector or string array.

Example: 'vdp' "f14/Aircraft Dynamics Model"

Block type, specified as a character vector or string array. Use get_param with the 'BlockType' parameter to get the block type.

Search constraints, specified as a Simulink.FindOptions object.

Example: Simulink.FindOptions('SearchDepth',1)

Output Arguments

collapse all

Search results, returned as an array of handles.

Introduced in R2018a