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

5 views (last 30 days)
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!

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','/')

Categories

Find more on Modeling in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by