
This is indicated by the change in label for the Switch Case Action subsystem block and the Action Port block inside of it to the name case specifies that output port case is run when the input value is 1, 2, 3, 4, or 5. Each connected subsystem becomes a case body.Connect each case output port and the default output port of the Switch Case block to the Action port of an Action subsystem.When you place the Action Port block inside a subsystem, the subsystem becomes an atomic subsystem with an input port labeled Action. These consist of subsystems with Action Port blocks inside them.Create a Switch Case Action subsystem for each case port you added to the Switch Case block.If all other cases are false, the default case is taken. Select the Show default case check box to show a default case output.See the Case conditions field in the "Parameters and Dialog Box" section of this reference. Enter the Case conditions field with the individual cases.Įach case can be an integer or set of integers specified with MATLAB cell notation.Open the Block Parameters dialog of the Switch Case block and enter as follows:.Place a Switch Case block in the current system and attach the input port labeled u1 to the source of the data you are evaluating.You construct a Simulink switch control flow statement like the example shown as follows: The preceding switch control flow statement can be represented by the following pseudocode: If a case value (in brackets) corresponds to the actual value of the input, its Switch Case Action subsystem is executed. The cases are evaluated top down starting with the top case. Each output port case condition is attached to a Switch Case Action subsystem. The following shows a completed Simulink C-like switch control flow statement in the subsystem of the Switch Case block.Ī Switch Case block receives a single input, which it uses to form case conditions that determine which the subsystem to execute. Implement a C-like switch control flow statement Switch Case (Simulink Reference) Simulink Reference
