Viktor Mellgren
Viktor Mellgren

Reputation: 4506

find_system returns objects that are not subsystems in simulink?

When I use find_system(gcs,'BlockType','SubSystem') it returns things that are not subsystems (AFAIK)

In my case the things that are called

subsys L1 -x

and

SubsysX L2 - z

are subsystems, but the names are just for debugging purpose, so I can't use the names to match.

Why is [1x51 char] and Sine and RealisesUID appearing?

I only want the subsystems showing up in the Model Browser tree.

'test_simulinkmodel/RealisesUID'
'test_simulinkmodel/subsys L1 - 1'
[1x51 char]
'test_simulinkmodel/subsys L1 - 1/Sine'
'test_simulinkmodel/subsys L1 - 1/Subsys1 L2 - 1'
[1x71 char]
[1x68 char]
'test_simulinkmodel/subsys L1 - 2'
[1x51 char]
'test_simulinkmodel/subsys L1 - 2/Sine'
'test_simulinkmodel/subsys L1 - 2/Subsys2 L2 - 1'
[1x71 char]
[1x68 char]
'test_simulinkmodel/subsys L1 - 3'
[1x51 char]
'test_simulinkmodel/subsys L1 - 3/Sine'
'test_simulinkmodel/subsys L1 - 3/Subsys3 L2 - 1'
[1x71 char]
[1x68 char]

EDIT: They show up in the model browswer if i select include library links and include systems with mask parameters. However, the default of find_system is 'FollowLinks' 'off' and 'LookUnderMasks' doesn't say. However, even if i provide explicit off and none, they still return the same result.

Upvotes: 0

Views: 5574

Answers (3)

Navan
Navan

Reputation: 4477

You can add LinkStatus parameter to find_system to look for only your own sub-systems and not the ones from libraries. find_system(gcs,'BlockType','SubSystem','LinkStatus','none'). The same way you can also add 'Mask' with 'on' or 'off' values to filter based on whether the block has a mask on it.

Is "Sine" a sub-system from your own library? Sine wave block from Simulink library would not show up if you search for 'BlockType' of 'SubSystem'.

Upvotes: 2

Mohsen Nosratinia
Mohsen Nosratinia

Reputation: 9864

You seem to get all subsystems within subsystems as a result. As suggested by am304 you can limit the search by using SearchDepthoption, but I usually find it easier to use Parent to limit the level of search. In your case

find_system(gcs,'Parent', 'test_simulinkmodel', 'BlockType', 'SubSystem');

Upvotes: 0

am304
am304

Reputation: 13876

I suspect the Sine block is a subsystem if you were to look under the mask, you would probably find an S-function. You can maybe specify a 'SearchDepth' argument to find_system or set 'LookUnderMasks' to 'none' (assuming your actual subsystems subsys L1 -x and SubsysX L2 - z aren't masked).

http://www.mathworks.co.uk/help/simulink/slref/find_system.html

Upvotes: 0

Related Questions