Package: Simulink
Superclasses:
Options for finding blocks in models and subsystems
Create an options object to use with Simulink.findBlocks
and
Simulink.findBlocksOfType
to constrain the search.
creates a
f
= Simulink.FindOptionsFindOptions
object that uses the default search options.
creates the object using the specified search options.f
= Simulink.FindOptions(Option1,Value1,...OptionN,ValueN)
'CaseSensitive'
— Option to specify whether to match case when searchingtrue
(default) | false
Option to specify whether to match case when searching, specified as
true
for case-sensitive search or
false
for case-insensitive search.
'FollowLinks'
— Option to follow library linksfalse
(default) | true
Option to follow library links, specified as true
or false
. If true
, search follows
links into library blocks.
'IncludeCommented'
— Option for the search to include commented blockstrue
(default) | false
Option for the search to include commented blocks, specified as
true
or false
.
'LookUnderMasks'
— Options to search masked blocks'all'
(default) | 'none'
| 'functional'
| 'graphical'
Options to search masked blocks, specified as:
'all'
— Search in all masked
blocks.
'none'
— Prevent searching in masked
systems.
'functional'
— Include masked
subsystems that do not have dialogs.
'graphical'
— Include masked subsystems
that do not have workspaces or dialogs.
'Variants'
— Options to search Variant subsystems'AllVariants'
(default) | 'ActiveVariants'
| 'ActivePlusCodeVariants'
Options to search Variant subsystems, specified as:
'AllVariants'
— Search all variant
choices.
'ActiveVariants'
— Search only active
variant choices.
'ActivePlusCodeVariants'
— Search all
variant choices with 'Generate preprocessor
conditionals'
active. Otherwise, search only the
active variant choices.
The 'Variants'
search constraint applies only to
variant subsystems and model variants.
'RegExp'
— Option to treat the search text as a regular expressionfalse
(default) | true
Option to treat the search text as a regular expression, specified as
true
or false
. To learn more
about MATLAB® regular expressions, see Regular Expressions (MATLAB).
'SearchDepth'
— Levels in the model to searchLevels in the model to search, specified as a positive integer. The default is to search all levels. Specify:
1
— Search in the top-level system.
2
— Search the top-level system and its
children, 3
to search an additional level,
and so on.
Simulink.findBlocks
Search for all blocks in the Unlocked subsystem but not in any of its children.
f = Simulink.FindOptions('SearchDepth',1); load_system('sldemo_clutch'); bl = Simulink.findBlocks('sldemo_clutch/Unlocked',f)
bl = 1.0e+03 * 1.1140 1.1150 1.1160 1.1170 1.1180 1.1190 1.1200 1.1210 1.1220 1.1230 1.1240 1.1250 1.1260 1.1270 1.1280 1.1290 1.1300 1.1310 1.1320 1.1330
To get the block name and path instead of the handle, use
getfullname
.
bl = getfullname (Simulink.findBlocks('sldemo_clutch/Unlocked',f))
bl = 20×1 cell array {'sldemo_clutch/Unlocked/Tfmaxk' } {'sldemo_clutch/Unlocked/Tin' } {'sldemo_clutch/Unlocked/Enable' } {'sldemo_clutch/Unlocked/E_Sum' } {'sldemo_clutch/Unlocked/Engine↵Damping' } {'sldemo_clutch/Unlocked/Engine↵Inertia' } {'sldemo_clutch/Unlocked/Engine↵Integrator' } {'sldemo_clutch/Unlocked/Goto' } {'sldemo_clutch/Unlocked/Goto1' } {'sldemo_clutch/Unlocked/Max↵Dynamic↵Friction↵Torque'} {'sldemo_clutch/Unlocked/V_Sum' } {'sldemo_clutch/Unlocked/Vehicle↵Damping' } {'sldemo_clutch/Unlocked/Vehicle↵Inertia' } {'sldemo_clutch/Unlocked/Vehicle↵Integrator' } {'sldemo_clutch/Unlocked/W_Slip' } {'sldemo_clutch/Unlocked/slip direction' } {'sldemo_clutch/Unlocked/w0' } {'sldemo_clutch/Unlocked/w0 ' } {'sldemo_clutch/Unlocked/we' } {'sldemo_clutch/Unlocked/wv' }