| Contents | Index |
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 hides the name of a Mux 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. MathWorks discourages using Mux blocks to create bus signals, and might not support this practice in future releases. See Avoiding Mux/Bus Mixtures for more information. |
Use the Number of inputs parameter to specify input signal names and sizes as well as the number of inputs. You can use one of the following formats:
| Format | Block Behavior |
|---|---|
Scalar | Specifies the number of inputs to the Mux block. When you use this format, the block accepts scalar or vector signals of any size. Simulink 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, an error message appears. 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 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. |
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 might have no unique capabilities and might be deprecated.
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, MathWorks discourages this practice. See Avoiding Mux/Bus Mixtures for more information.
The Mux block accepts real or complex signals of any data type that Simulink supports, including fixed-point and enumerated data types.
For more information, 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.
The sf_car model uses a Mux block to combine two signals for input to a Scope block:

The sf_aircontrol model uses a Mux block to combine two signals for input to a Stateflow chart:

The following models also show how to use the Mux block:
sldemo_auto_climatecontrol
sldemo_suspn
sldemo_zeroxing
penddemo
Virtual | Yes For more information, see Virtual Blocks in the Simulink documentation. |

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