| Simulink Reference | ![]() |
Switch output between the first input and the third input based on the value of the second input
Library
Description
The Switch block passes through the first (top) input or the third (bottom) input based on the value of the second (middle) input. The first and third inputs are called data inputs. The second input is called the control input.
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, then the first input is passed. Otherwise, the third input is passed.
| Note If the data inputs to the switch are buses, the element names of both buses must be the same to ensure that the output bus has the same element names no matter which input bus is selected. You can ensure that your model meets this requirement by using a bus object to define the buses with the model's Element name mismatch diagnostic set to error. See Connectivity Diagnostics for more information. |
Data Type Support
The data and control inputs of a Switch block accept real or complex signals of any data type supported by Simulink, including fixed-point data types.
For a discussion on the data types supported by Simulink, refer to Data Types Supported by Simulink in the Using Simulink documentation.
Parameters and Dialog Box
The Main pane of the Switch block dialog appears as follows:
-1. See Specifying Sample Time in the online documentation for more information.
The Signal data types pane of the Switch block dialog appears as follows:
Characteristics
| Direct Feedthrough |
Yes |
| Sample Time |
Specified in the Sample time parameter |
| Scalar Expansion |
Yes |
| Dimensionalized |
Yes |
| Zero Crossing |
Yes, if enabled |
See Also
| Sum of Elements | Switch Case | ![]() |
© 1994-2005 The MathWorks, Inc.