Why does the Simulink.VariantExpression object in R2023b does not seem to be compatible with the Simulink.Variant object in R2017b
Show older comments
Our company uses the same Simulink model in MATLAB R2017b and R2023b which contains variant subsystems. Unfortunatley we need to continue using our R2017b due third party contractors.
The way the variants were used within R2017b and in R2023a was by Simulink.Variant object and defined in the base workspace. Variant controls are switched using conditional expressions.
Typing the following into the command window in either R2017b or R2023a creates the variant variable as expected.
variantTest1 = Simulink.Variant('config1' || 'config2')
variantTest1 =
Simulink.Variant
Condition: 'config1' || 'config2'
When variables were created in the workspace as shown below, they were then saved to .mat file which was added to the project, and set to open on startup.
config1 1x1 Variant
config2 1x1 Variant
However, recently I had to add another variant subsystem in R2023b, which I did the same was as usual, however it was now a variantExpression instead of being Simulink.Variant as per below.
variantTest2 = Simulink.Variant('config3' || 'config4')
variantTest2 =
VariantExpression with properties:
Condition: 'config3' || 'config4'
This didn't bother me at the time because I could compile the model fine and it appeared very similar in the workspace as 1x1 VariantExpression, however when a colleague using R2017b loaded the model they noticed that the
workspace variable was now a 6x 1 Vector with the elements being of double data type as shown below.
config3 [3707764736;2;1;1;1;1]
config4 [3707764736;2;1;1;2;2]
I have since seen that the Simulink.VariantExpression object class has been introduced in R2023b which is why I have not seen this issue before, however why is this not backwards compatible with R2017b when creating and using variants under the same context?
I noticed while viewing the block parameters GUI within Simulink that there are two variant drop down options for control mode and activation time. I have left these and not changed them and they are currently set as expression and update diagram respectively.
Could I please receive some guidance as to how I can resolve this problem programatically if possible?
Currently, the work around is to delete and re-create the variant variable in the workspace in R2017b, however it would be much more preferrable to not have to do that.
Regards,
Dan
Accepted Answer
More Answers (0)
Categories
Find more on Model, Block, and Port Callbacks 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!