Main Content

If-Then-Else Blocks

This example shows what happens when a sine wave is fed into an If block, and is designed to compare the If block with enabled subsystems.

After running the simulation, the scope shows three plots. The first of these plots shows the original sine wave and the absolute value of the original sine wave offset by two. The absolute value of the sine wave is shown only when the subsystem is executed. This occurs between 0 and 2.5 seconds, and between 5 and 7.5 seconds. When the subsystem is not executed, the output of the subsystem is reset to 0. The value of 0 is determined by the initial condition of the outport. You can see when the subsystem is executed by looking at the second plot. A value of 1 indicates that it is executed.

The second plot shows the original value of the input signal. When the signal is towards the top of the plot, the if subsystem related to the first plot is executed. When the signal is towards the bottom of the plot, the else subsystem related to the third plot is executed.

The third plot shows the original sine wave and the saturation-limited sine wave offset by two. The saturated value of the sine wave is shown only when the subsystem is executed. This occurs between 2.5 and 5 seconds, and between 7.5 and 10 seconds.