MATLAB Answers

Search for all the Divide block in a subsystem and its children

3 views (last 30 days)
Ubaldo
Ubaldo on 17 Aug 2017
Hello,
I am trying to find for all the Divide blocks in a model subsystem (and its children) but with no success. Here is the code that I use
Global_path = 'MyModel/MySubsystem';
blks = find_system(Global_path,'BlockType','Divide');
but with no success. On the other hand, as I think that Divide block is basically a Product block, I use this syntax instead:
Global_path = 'MyModel/MySubsystem';
blks = find_system(Global_path,'BlockType','Product','Inputs', '*/');
The latter code seems to work a bit better. However, I have two questions:
1. Are we sure that I am searching only in 'MyModel/MySubsystem'? I DON'T want to search in any other submodel, i.e. 'MyModel/AnotherSubsystem' shall be exluded
2. This method is not very robust as it search only blocks that has exactly '*/' as input. If I have a block that instead would have '**/' will be excluded. How can I robustify my code? For example by searching for all the blocks that CONTAIN the string '/'?
Many thanks!

  0 Comments

Sign in to comment.

Answers (1)

Sharan Paramasivam Murugesan
1. Yes, find_system function will search only under the system you specify.
2. Use the option "RegExp" with value "on" i.e., blks = find_system(Global_path,'RegExp','on','BlockType','Product','Inputs','/')

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by