Main Content

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

Open the example. Then, load the vdp model.

load_system('vdp')

Get the handles of all the Integrator blocks in the vdp model.

Simulink.findBlocksOfType('vdp','Integrator')
ans = 2×1

  334.0022
  357.0027

To return block names instead of handles, use the getfullname function.

getfullname(Simulink.findBlocksOfType('vdp','Integrator'))
ans = 2x1 cell
    {'vdp/x1'}
    {'vdp/x2'}

Open the example. Then, load the sldemo_clutch model.

load_system('sldemo_clutch')

Create a FindOptions object.

f = Simulink.FindOptions('SearchDepth',1);

Use the object to constrain the search of Goto blocks in the model to the Unlocked subsystem.

b = Simulink.findBlocksOfType('sldemo_clutch/Unlocked','Goto',f)
b = 2×1

  676.0015
  678.0015

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 scalar. 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.

Version History

Introduced in R2018a