Main Content

Simulink.findBlocks

Find blocks in Simulink models

Description

example

bl = Simulink.findBlocks(sys) returns handles to all blocks in the model or subsystem sys.

bl = Simulink.findBlocks(sys,options) finds blocks that match the criteria specified by a Simulink.FindOptions object.

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

bl = Simulink.findBlocks(sys,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

Return handles for all blocks in the model vdp.

load_system('vdp');
bl = Simulink.findBlocks('vdp')
bl =

   1.0e+03 *

    9.4450
    9.4460
    9.4470
    9.4480
    9.4490
    9.4500
    9.4510
    9.4520
    9.4530
    9.4540
    9.4550
    9.4560
    9.4570
    9.4580

Return block names.

bl = getfullname(Simulink.findBlocks('vdp'))
bl =

  14×1 cell array

    {'vdp/Constant'            }
    {'vdp/More Info'           }
    {'vdp/More Info/Model Info'}
    {'vdp/Mu'                  }
    {'vdp/Mux'                 }
    {'vdp/Product'             }
    {'vdp/Scope'               }
    {'vdp/Square'              }
    {'vdp/Sum'                 }
    {'vdp/Sum1'                }
    {'vdp/x1'                  }
    {'vdp/x2'                  }
    {'vdp/Out1'                }
    {'vdp/Out2'                }

Return block handles for the block whose name is Mu.

Simulink.findBlocks('vdp','Name','Mu')
ans =

   9.4480e+03

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"

Search constraints, specified as a Simulink.FindOptions object.

Output Arguments

collapse all

Search results, returned as an array of handles.

Introduced in R2018a