Find systems, blocks, lines, ports, and annotations


find_system(sys, 'c1', cv1, 'c2', cv2,...'p1', v1, 'p2', v2,...)


find_system(sys, 'c1', cv1, 'c2', cv2,...'p1', v1, 'p2', v2,...) searches the loaded systems or subsystems specified by sys, using the constraints c1, c2 etc., with values cv1, cv2, etc., and returns handles or paths to the objects whose parameters, p1, p2, etc., have the values v1, v2, etc. The sys argument can be a pathname (or cell array of pathnames), a handle (or vector of handles), or omitted. To search block dialog parameter values, specify 'BlockDialogParams' as the parameter name.

    Note   All the search constraints must precede all the parameter-value pairs in the argument list.

If sys is a pathname or cell array of pathnames, find_system returns a cell array of pathnames of the objects it finds. If sys is a handle or a vector of handles, find_system returns a vector of handles to the objects that it finds. If sys is omitted, find_system searches all loaded systems and returns a cell array of pathnames.

Case is ignored for parameter names. Value strings are case sensitive by default (see the 'CaseSensitive' search constraint for more information). Any parameters that correspond to dialog box entries have string values. See Model Parameters and Block-Specific Parameters for a list of model and block parameters.

You can specify any of the following search constraints.


Value Type




Restricts the search depth to the specified level (0 for loaded systems only, 1 for blocks and subsystems of the top-level system, 2 for the top-level system and its children, etc.). The default is all levels.



Search skips masked subsystems.


Search includes masked subsystems that have no workspaces and no dialogs. This is the default.


Search includes masked subsystems that do not have dialogs.


Search includes all masked subsystems.


'on' | {'off'}

If 'on', search follows links into library blocks. The default is 'off'.


'on' | {'off'}

If 'on', search extends to lines, ports, and annotations within systems. The default is 'off'. Note that find_system returns a vector of handles when this option is 'on', regardless of the array type of sys.


{'on'} | 'off'

If 'on', search considers case when matching search strings. The default is 'on'.


'on' | {'off'}

If 'on', search treats search expressions as regular expressions. Use to search for partial matches. The default is'off'.

See Searching with Regular Expressions.


{'on'} | 'off'

If 'on', attempts to load any partially loaded models. The default is'on'. If 'off', disables the model loading, for example to prevent load warnings.



(Default) Search in only the active variant subsystems.


Search in all variants.


Search all variants if any generate preprocessor conditionals. Otherwise, search only the active variant.


'on' | {'off'}

Specify whether to include commented blocks in the search.

The table indicates default constraint values in brackets. If you omit a 'constraint', find_system uses the default constraint value.


This command returns a cell array containing the names of all loaded systems and blocks.


This command returns the names of all loaded block diagrams.

open_bd = find_system('type', 'block_diagram')

This command returns the names of all Goto blocks that are children of the Unlocked subsystem in the sldemo_clutch system.


These commands return the names of all Gain blocks in the vdp system having a Gain parameter value of 1.

gb = find_system('vdp', 'BlockType', 'Gain')
find_system(gb, 'Gain', '1')

The preceding two commands are equivalent to this command:

find_system('vdp', 'BlockType', 'Gain', 'Gain', '1')

These commands obtain the handles of all lines and annotations in the vdp system.

sys = get_param('vdp', 'Handle');
l = find_system(sys, 'FindAll', 'on', 'type', 'line');
a = find_system(sys, 'FindAll', 'on', 'type', 

Turn off the LoadFullyIfNeeded search constraint.


Search for partial matches for X within any block dialog parameter value:

find_system('Regexp', 'on', 'BlockDialogParams','X')

Searching for Blocks with a Specific Tag

Use the block Tag property to search for blocks.

  1. Open the vdp model.

  2. Right-click the Sum block, and from the menu, select Properties. The Block Properties: Sum dialog opens.

  3. In the Tag box, enter sum blocks, and then click OK.

  4. Search for the tag sum blocks.

    find_system('vdp', 'Tag', 'sum blocks')
    ans = 

Searching Block Dialog Parameter Values

Use the parameter 'BlockDialogParams' to search block dialog parameter values. For example, to find any block which has a dialog parameter whose value is the string 'X+1', enter:


To find any partial matches within parameter values, for any find_system command, first specify the option 'Regexp', 'on'. For the example above, to find X within the parameter value 'X+1', enter:

find_system('Regexp', 'on', 'BlockDialogParams','X')

Searching with Regular Expressions

If you specify the 'RegExp' constraint as 'on', find_system treats search value strings as regular expressions. A regular expression is a string of characters in which some characters have special pattern-matching significance. For details, see Regular Expressions.

Regular expressions greatly expand the types of searches you can perform with find_system. For example, regular expressions allow you to do partial-word searches. You can search for all objects that have a specified parameter that contains or begins or ends with a specified string of characters.

To use regular expressions to search Simulink® systems, specify the 'regexp' search constraint as 'on' in a find_system command and use a regular expression anywhere you would use an ordinary search value string.

For example, the following command finds all the inport and outport blocks in the sldemo_clutch model that is provided with Simulink software.

find_system('sldemo_clutch', 'regexp', 'on', 'blocktype', 'port')

Introduced before R2006a

Was this topic helpful?