Switch

Switch output between first input and third input based on value of second input

Library

Signal Routing

Description

The Switch block passes through the first input or the third input based on the value of the second input. The first and third inputs are called data inputs. The second input is called the control input. (See Changing the Orientation of a Block in the Simulink® documentation for a description of the port order for various block orientations.)

You select the conditions under which the first input is passed with the Criteria for passing first input parameter. You can make the block check whether the control input is greater than or equal to the threshold value, purely greater than the threshold value, or nonzero. If the control input meets the condition set in the Criteria for passing first input parameter, the first input is passed. Otherwise, the third input is passed.

Data Type Support

The control and data inputs of a Switch block can be signals of any data type supported by Simulink software, including fixed-point data types. However, the control input must be real; the data inputs can be real or complex.

For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink® in the Simulink documentation.

Parameters and Dialog Box

The Main pane of the Switch block dialog appears as follows:

Criteria for passing first input

Select the conditions under which the first input is passed. You can make the block check whether the control input is greater than or equal to the threshold value, purely greater than the threshold value, or nonzero. If the control input meets the condition set in this parameter, then the first input is passed. Otherwise, the third input is passed.

Threshold

Assign the switch threshold that determines which input is passed to the output.

Enable zero crossing detection

Select to enable zero crossing detection. For more information, see Zero Crossing Detection.

Sample time (-1 for inherited)

Specify the time interval between samples. To inherit the sample time, set this parameter to -1. See Specifying Sample Time in the online documentation for more information.

The Signal Attributes pane of the Switch block dialog appears as follows:

Require all data port inputs to have the same data type

Select to require all data inputs to have the same data type.

Output minimum

Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:

Output maximum

Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:

Output data type

Specify the output data type. You can set it to:

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Specifying Block Output Data Types for more information.

Lock output scaling against changes by the autoscaling tool

Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.

Round integer calculations toward

Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink® Fixed Point™ User's Guide.

Saturate on integer overflow

Select to have overflows saturate.

Bus Support

The Switch block is a bus-capable block. The inputs can be virtual or nonvirtual bus signals subject to the following restrictions:

Characteristics

Bus-capableYes, with restrictions as noted above

Direct Feedthrough

Yes

Sample Time

Specified in the Sample time parameter

Scalar Expansion

Yes

Dimensionalized

Yes

Multidimensionalized

Yes

Zero Crossing

Yes, if enabled

See Also

Multiport Switch

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS