Question

I want to use scripting to create and define a variant subsystem in simulink.

I am able to create the variant subsystem and add subsystems within it using the add_block but cannot find the appropriate property that defines the variant subsystem by using the get_param command.

The way I graphically configure a variant subsystem is by right clicking the block and going to Block Parameters and then adding the variant control conditions for each subsystem.

I want to do the same thing but from an m-file so that I can create multiple blocks programmatically.

I checked the documentation and google search but couldn't find anything.

Thanks in advance.

Was it helpful?

Solution

Based on a comment by @Praetorian, I opened the model in a text editor and found the parameter line where the variant condition was defined.

I found that the variant conditions are stored in the subsystems within the variant subsystem and not within the top-level variant subsystem.

So you store the condition within each subsystem's "VariantControl" parameter.

Example: set_param([variantSys '/' sys],'VariantControl','a==1') where sys is a subsystem within the variant subsystem variantSys.

OTHER TIPS

The variant control should be written on the Callbacks of the Model. In order to put the simulink variant controls available to the model, the variables should be created in the workspace. For this to happen you need to put your Sys = Simulink.Variant(Mode== value) etc on the PreLoadFcn.

Check access PreLoadFcn and put the formulas in there then your table will be automatically filled.

If you do not mind can you tell me how you created the variant subsystem?

Good luck

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top