| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Simulink |
| Contents | Index |
| Learn more about Simulink |
Signal Routing
The Mux block combines its inputs into a single vector output. An input can be a scalar or vector signal. All inputs must be of the same data type and numeric type. The elements of the vector output signal take their order from the top to bottom, or left to right, input port signals. See How to Rotate a Block for a description of the port order for various block orientations. To avoid adding clutter to a model, Simulink software hides the name of a Demux block when you copy it from the Simulink library to a model. See Mux Signals for information about creating and decomposing vectors.
Note The Mux block allows you to connect signals of differing data and numeric types and matrix signals to its inputs. In this case, the Mux block acts like a Bus Creator block and outputs a bus signal rather than a vector. The MathWorks discourages using mux blocks to create bus signals, and may not support this practice in future releases. See Avoiding Mux/Bus Mixtures for more information. |
The Mux block's Number of Inputs parameter allows you to specify input signal names and sizes as well as the number of inputs. You can use any of the following formats to specify this parameter:
Scalar
Specifies the number of inputs to the Mux block. When this format is used, the block accepts scalar or vector signals of any size. Simulink software assigns each input the name signalN, where N is the input port number.
Vector
The length of the vector specifies the number of inputs. Each element specifies the size of the corresponding input. A positive value specifies that the corresponding port can accept only vectors of that size. For example, [2 3] specifies two input ports of sizes 2 and 3, respectively. If an input signal width does not match the expected width, Simulink software displays an error message. A value of -1 specifies that the corresponding port can accept scalars or vectors of any size.
Cell array
The length of the cell array specifies the number of inputs. The value of each cell specifies the size of the corresponding input. A scalar value N specifies a vector of size N. A value of -1 means that the corresponding port can accept scalar or vector signals of any size.
Signal name list
You can enter a list of signal names separated by commas. Simulink software assigns each name to the corresponding port and signal. For example, if you enter position,velocity, the Mux block will have two inputs, named position and velocity.
The MathWorks encourages using Vector Concatenate blocks rather than Mux blocks to combine vectors. The primary exception is the creation of a vector of function calls, which requires a Mux block. In future releases, Mux blocks may have no unique capabilities and may be deprecated.
If you want to create a composite signal, in which the constituent signals retain their identities and can have different data types, use a Bus Creator block rather than a Mux block. Although you can use a Mux block to create a composite signal, The MathWorks discourages this practice. See Avoiding Mux/Bus Mixtures for more information.
The Mux block accepts real or complex signals of any data type supported by Simulink software, including fixed-point and enumerated data types.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink in the Simulink documentation.

Specify number and size of inputs.
Default: 2
You can enter a comma-separated list of signal names for this parameter field.
See Block-Specific Parameters for the command-line information.
Specify the appearance of the block in the model.
Default: bar
Displays the block in a solid foreground color
Mux appears inside the block
Displays signal names next to each port
See Block-Specific Parameters for the command-line information.
Virtual | Yes For more information, see Virtual Blocks in the Simulink documentation. |
![]() | Multiport Switch | Outport | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |