Why do I get warnings about a 'Variants' argument in Simulink R2022b and later?

조회 수: 34 (최근 30일)
While working on my Simulink model in R2022b or later, I encounter the following warning:
Warning: Using find_system without the 'Variants' argument skips inactive Variant 
Subsystem blocks in the search. This behavior will change in a future release to 
look at all choices of the Variant Subsystem. To find blocks that are active in 
simulation or code generation, compile the model and use the built-in variant 
filters with the 'MatchFilter' option. To find all blocks use filter
'@Simulink.match.allVariants' with the 'MatchFilter' option. 
Or warnings similar to the following:
Warning: 'Variants' will be removed. Instead of using 'Variants' with value set to
'AllVariants', use 'MatchFilter' with value set to '@Simulink.match.allVariants'.
Why is this happening and how can I turn these warnings off?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 2월 8일
편집: MathWorks Support Team 2024년 2월 8일

What This Issue Means

The warnings are caused by using the 'find_system' function, or related functions such as 'libinfo', on a model with Variant Subsystems in R2022b or later. The warnings are due to the 'Variants' argument of these functions being deprecated in a future release of MATLAB.
Refer to the "Version History" section of the 'find_system' documentation for detailed information regarding this change:https://www.mathworks.com/help/simulink/slref/find_system.html#mw_701aa577-b30f-4f10-bf9a-19be1eab185b
 

Try These Workarounds

To find all blocks, use the filter '@Simulink.match.allVariants' with the 'MatchFilter' option. An example of this can be seen in the following code:
>> find_system(model, 'MatchFilter', @Simulink.match.allVariants);
To find only blocks that are active in simulation, compile the model and use the filter '@Simulink.match.activeVariants' with the 'MatchFilter' option:
>> set_param(model,'SimulationCommand','update');
>> find_system(model, 'MatchFilter', @Simulink.match.activeVariants);
See the "Find Variant Blocks Using Built-In Filter Functions" section for more details and examples:
 

Additional Notes:

1) If you would like to ignore these warnings and turn them off, then you can do so using the following commands:
>> warning('off','Simulink:Commands:FindSystemDefaultVariantsOptionWithVariantModel')
>> warning('off','Simulink:Commands:FindSystemAllVariantsRemoval')
>> warning('off','Simulink:Commands:FindSystemVariantsOptionRemoval')
2) If you are unsure where there is a call to 'find_system' or 'libinfo' in your environment or project, you can use the command:
>> lastwarn
and inspect the warning stack or send it to MathWorks Technical Support. In case the warning stack points to third-party toolboxes or environments, reach out to the support teams for these external products.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by