The find_mdlrefs function used with new 'MatchFilter' ActiveVariants option doesn't return the same as the 'Variant'
3 views (last 30 days)
Show older comments
Following the warning :
Warning: 'Variants' will be removed. Instead of using 'Variants' with value set to 'AllVariants', use 'MatchFilter' with value set to '@Simulink.match.allVariants'.
I changed to 'MatchFilter' But the new 'MatchFilter' option, when used with @Simulink.match.activeVariants, doesn't return the same as the 'Variants' option with 'ActiveVariants'.
To test, I used the following code:
models = find_mdlrefs(mainModelName, 'LookUnderMasks','off','MatchFilter', @Simulink.match.activeVariants,'FollowLinks', 'on','IncludeCommented','off');
models1 = find_mdlrefs(mainModelName, 'LookUnderMasks','off','MatchFilter', @Simulink.match.allVariants,'FollowLinks', 'on','IncludeCommented','off');
models2 = find_mdlrefs(mainModelName, 'LookUnderMasks','off','Variants','ActiveVariants','FollowLinks', 'on','IncludeCommented','off');
models3 = find_mdlrefs(mainModelName, 'LookUnderMasks','off','Variants','AllVariants','FollowLinks', 'on','IncludeCommented','off');
length(models)
length(models1)
length(models2)
length(models3)
Which returned:
ans = 95 (MatchFilter/@Simulink.match.activeVariants)
ans = 95 ('MatchFilter/@Simulink.match.allVariants)
ans = 78 ('Variants'/ActiveVariants)
ans = 95 ('Variants'/AllVariants)
I found a bug report on the same subject : https://www.mathworks.com/support/bugreports/2341865#
But the Fix options is to upgrade to R2021b and I am using R2023a so the fix doesn't seem to be working for me
0 Comments
Accepted Answer
Aiswarya
on 8 Apr 2024
Hi noe,
The "MatchFilter" option is the recommended replacement for the "Variants" argument in "find_mdlrefs" function. But the Simulink.match.activeVariants and Simulink.match.codeCompileVariants are post-compile time filter functions. In order to get correct results you should first compile the model before using these filters. If the model is not compiled, these filters return all blocks in the model. You can compile the model using the following command:
set_param(model,'SimulationCommand','update');
And then use your "find_mdlrefs" command with the Simulink.match.activeVariants filter:
models = find_mdlrefs(mainModelName, 'LookUnderMasks','off','MatchFilter', @Simulink.match.activeVariants,'FollowLinks', 'on','IncludeCommented','off');
You may refer to the following documentation for more information on the "MatchFilter" option:
1 Comment
Wolfgang Soergel
on 8 Apr 2024
Yes, the need to compile before is documented and then delivers the same results. However this is not really satisfactory to me due to performance issues with bigger models: One of my practival applications takes less than 1 second for the actual find_mdlrefs operation.
However the compilation takes at least 90 seconds (and much more on slower machines with less memory) for the models in question. So a once quick function where the result was available without noticable delay now requires getting a cup of coffee or an annoying "task switch" during work. Unfortunately this is just one more piece in a trend we observe since some years that all kinds or working tasks with Simulink, like searching, updating models or building with Simulink Coder tend to take longer and longer, despite faster computers and roughly comparable models. I still occcasionally work with R2016b on some models and again and again i'm amazed how quick things were back then...
More Answers (0)
See Also
Categories
Find more on Programmatic Model Editing 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!