Variant Model block inside Referenced Model - Error during "sim" call from function

1 view (last 30 days)
Variant model block gives a lot of opportunity. But when I want to call model from m-function (not script) using sim command with 'SrcWorkspace' = 'current' settings, it returns error. There are no error when I calling it from m-script. I suppose there is an error in Variant model block implementation.
Is there any workaround?
I can use variant control object and variables that using for decision in the base workspace, but this is not an option for me, because I want to call m-function in the parfor loop and use only function parameters.
Examples with and without error in attachment. mymodel_4.slx contain reference to model mRef2.slx, witch have Model Variant block with variant control objects to reference on models modA.slx or modB.slx.
>> simFromScript
mymodel_1 - OK
mymodel_2 - OK
mymodel_3 - OK
mymodel_4 - OK
>> clear
>> simFromFunction(1)
mymodel_1 - OK
mymodel_2 - OK
mymodel_3 - OK
Error using simFromFunction (line 17)
Error due to multiple causes.
Caused by:
Error using simFromFunction (line 17)
The variant control 'VAR_MOD_A' of the variant block 'mRef2/Model Variants' must be a condition
expression or name of a Simulink.Variant object in the global scope workspace of the model.
Error using simFromFunction (line 17)
The variant control 'VAR_MOD_B' of the variant block 'mRef2/Model Variants' must be a condition
expression or name of a Simulink.Variant object in the global scope workspace of the model.

Answers (0)

Categories

Find more on Component-Based 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!