Search code examples
virtualsimulink

How to toggle between a virtual and nonvirtual block in Simulink?


In Simulink library browser - Subsystem examples - Virtual and nonvirtual subsystem overview, the difference between a virtual subsystem and nonvirtual subsystem is explained:

enter image description here

My question is how you can toggle between a virtual and nonvirtual block. I guess it is simple, but I cannot find it. Or do I understand it wrongly?


Solution

  • To do it manually,

    1. Right-click on the subsystem
    2. Select Block Parameters (Subsytem)
    3. Check the 'Treat as Atomic Unit' selection box

    To do it from within code, assuming that the block has been selected,

    set_param(gcb,'TreatAsAtomicUnit','on'); % turns it on
    set_param(gcb,'TreatAsAtomicUnit','off'); % turns it off