Be_bro
Be_bro

Reputation: 15

Finding SubSystems in a Simulink model using find_system() instruction in Matlab

I am trying to find all the SubSystems present in a Simulink model at a particular Level including the Subsystems from Third Party libraries. However, in the result I get some values instead of names of the SubSystems from Libraries.

Instruction Used:

find_system('Level1/Level2','SearchDepth',1,'LookUnderMasks','on','BlockType','SubSystem')

Result:

'Level1/Subsystem1'
'Level1/SubSystem2'
[1x11 char]
[1x90 char]
[1x34 char]

Upvotes: 0

Views: 9302

Answers (2)

am304
am304

Reputation: 13876

It's because find_system returns a cell array or vector of handles, see the documentation:

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.

Use an output argument when calling the function and you'll be able to explore the contents of the returned variable, e.g.:

my_sys = find_system('Level1/Level2','SearchDepth',1,'LookUnderMasks','on','BlockType','SubSystem');

Then you should be able to see what's in my_sys and access its contents.

Upvotes: 3

Daniel
Daniel

Reputation: 36710

The find_system method returns handles to simulink blocks. To get the name of the subsystem you have to use the getfullname function to get the names for the handles.

Upvotes: 2

Related Questions