| Simulink Reference | ![]() |
Find systems, blocks, lines, ports, and annotations.
Syntax
Description
find_system(sys, 'c1', cv1, 'c2', cv2,...'p1', v1, 'p2', v2,...) searches the systems or subsystems specified by sys, using the constraints specified by c1, c2, etc., and returns handles or paths to the objects having the specified parameter values v1, v2, etc. sys can be a pathname (or cell array of pathnames), a handle (or vector of handles), or omitted. 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 open 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 Appendix , "Model and Block Parameters, for a list of model and block parameters.
You can specify any of the following search constraints.
The table encloses default constraint values in brackets. If a 'constraint' is omitted, find_system uses the default constraint value.
Examples
This command returns a cell array containing the names of all open systems and blocks.
This command returns the names of all open block diagrams.
This command returns the names of all Goto blocks that are children of the Unlocked subsystem in the clutch system.
These commands return the names of all Gain blocks in the vdp system having a Gain parameter value of 1.
The preceding commands are equivalent to this command:
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', 'annotation');
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 example, a period (.) in a regular expression matches not only itself but any other character.
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 effectively, you need to learn the meanings of the special characters that regular expressions can contain. The following table lists the special characters supported by find_subystem and explains their usage.
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 clutch model demo provided with Simulink.
See Also
| delete_param | gcb | ![]() |