| Simulink® | ![]() |
Signal Routing

The Multiport Switch block chooses between a number of inputs. The first input is called the control input, while the rest of the inputs are called data inputs. The value of the control input determines which data input is passed through to the output port. (See Changing the Orientation of a Block in the Simulink documentation for a description of the port order for various block orientations.)
If the control input is an integer value, then the specified data input is passed through to the output. For example, suppose the Use zero-based indexing parameter is not selected. If the control input is 1, then the first data input is passed through to the output. If the control input is 2, then the second data input is passed through to the output, and so on. If the control input is not an integer value, the block first truncates the value to an integer by rounding to floor. If the truncated control input is less than 1 or greater than the number of input ports, an out-of-bounds error is returned.
You specify the number of data inputs with the Number of inputs parameter. The data inputs can be scalar or vector. The block output is determined by these rules:
If you specify only one data input and that input is a vector, the block behaves as an "index selector," and not as a multi-port switch. The block output is the vector element that corresponds to the value of the control input.
If you specify more than one data input, the block behaves like a multi-port switch. The block output is the data input that corresponds to the value of the control input. If at least one of the data inputs is a vector, the block output is a vector. Any scalar inputs are expanded to vectors.
If the inputs are scalar, the output is a scalar.
The Index Vector block, also in the Signal Routing library, is another implementation of the Multiport Switch block that has different default parameter settings.
The control signal can be of any data type supported by Simulink software, including fixed-point and enumerated types, except Boolean. If the control signal is numeric, it cannot be complex. If it is enumerated, the block uses the value of the underlying integer to select a data port. If the underlying integer does not correspond to a data port, an error occurs.
The data signals can be of any data type supported by Simulink software. If any data signal is of an enumerated type, all others must be of the same enumerated type.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink in the Simulink documentation.
The Main pane of the Multiport Switch block dialog appears as follows:

Specify the number of data inputs to the block.
If selected, the block uses zero-based indexing. Otherwise, the block uses one-based indexing.
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 Multiport Switch block dialog appears as follows:

Select to require all data port inputs to have the same data type.
Specify the minimum value that the block should output. The default value, [], is equivalent to -Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the maximum value that the block should output. The default value, [], is equivalent to Inf. Simulink software uses this value to perform:
Simulation range checking (see Checking Signal Ranges)
Automatic scaling of fixed-point data types
Specify the output data type. You can set it to:
A rule that inherits a data type, for example, Inherit: Inherit via back propagation
The name of a built-in data type, for example, single
The name of a data type object, for example, a Simulink.NumericType object
An expression that evaluates to a data type, for example, float('single')
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.
Select to lock scaling of outputs. This parameter is visible only if you enter an expression for the Output data type parameter.
Select the rounding mode for fixed-point operations. For more information, see Rounding in the Simulink Fixed Point User's Guide.
Select to have overflows saturate.
The Multiport Switch block is a bus-capable block. The inputs can be virtual or nonvirtual bus signals subject to the following restrictions:
The number of inputs must be greater than one.
All inputs to the merge must be buses and must be equivalent (same hierarchy with identical names and attributes for all elements).
All signals in a nonvirtual bus input to a Multiport Switch block must have the same sample time, even if the elements of the associated bus object specify inherited sample times. You can use a Rate Transition block to change the sample time of an individual signal, or of all signals in a bus. See Using Buses and Bus-Capable Blocks for more information.
| Bus-capable | Yes, 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 | No |
![]() | Model Info | Mux | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |