Using Simulink    

Creating Alternately Executing Subsystems

You can use conditionally executed subsystems in combination with Merge blocks to create sets of subsystems that execute alternately, depending on the current state of the model. For example, the following figure shows a model that uses two enabled blocks and a Merge block to model an inverter, that is, a device that converts AC current to pulsating DC current.

In this example, the block labeled "pos" is enabled when the AC waveform is positive; it passes the waveform unchanged to its output. The block labeled "neg" is enabled when the waveform is negative; it inverts the waveform. The Merge block passes the output of the currently enabled block to the Mux block, which passes the output, along with the original waveform, to the Scope block to create the following display.


 A Sample Triggered and Enabled Subsystem Block Reference