Change number of ports based on variant subsystem choice

27 ビュー (過去 30 日間)
Amish Rughoonundon
Amish Rughoonundon 2015 年 12 月 30 日
回答済み: Rakesh Chavan 2016 年 1 月 5 日
Hi I am learning how to create a custom library in matlab. I have attached the file I have so far.
I used a variant subsystem with a mask to allow a user to choose which subsystem to use I have three questions that is really confusing me
My subsystem has different number of input ports but when I choose a subsystem, I do not see that the top level variant subsystem block removes or adds the input port. It's always the maximum number of input ports. How do I make this happen?
In the variant control, I used mode==1, mode==2, etc to switch between subsystem. In my mask callback space, I then used if statements to set the mode based on the user choice in the mask popup. This seem to be adding variables (mode, AdderOptiopnChosen) in the matlab workspace.
What happens if a user deletes the workspace after setting the mask. Is there a way to have these variables contained in the subsystem workspace somehow?
Also is there a better way for the variant subsystem variant control to have access to the mask data somehow?
It seems every time I open the file variantSubsystemTest.slx and I double click on the variant subsystem block, the mask that appears has the popup option grayed out. I then have to unlock the library and then it lets me choose. How will that work when this will be integrated into the simulink library browser?
Thanks for the help, Amish


Rakesh Chavan
Rakesh Chavan 2016 年 1 月 5 日
I see that you have created a library containing your masked block.
For the 1st query: As of now the extra inputs are disabled by Simulink during Simulation or after a model update. To reduce the number of input ports on the main variant subsystem block we will have to remove the inactive 'inports' from within the variant subsystem.
However this will lead to an error even if the active variant has lesser number of inports. Kindly refer to the conditions for Inports given in the link below for more details.
For the 2nd query: If you delete the variant control variable from the MATLAB workspace the model will not work. 'mode' is the variant control variable in your model and hence it should be defined. Kindly refer to the following link for more details.
Another for passing the same parameter 'mode' directly in the mask instead of using two different parameters, one in the mask and another parameter for selecting the variant systems.
For your 3rd query: In order to use the block, drag it into a new Simulink model. If you try to use it directly from the library it is equivalent to making changes in the library which is why you need to unlock the library.

その他の回答 (0 件)


Help Center および File ExchangeVariant Hierarchical Components についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by