Using Simulink     Search    Help Desk 
Mux

Combine several input lines into a vector line.

Library

Signals & Systems

Description

The Mux block combines several input lines into one vector line. Each input line can carry a scalar or vector signal. The output of a Mux block is a vector.

You can assign names to the input signals by:

The default name for an unlabeled line or unconnected port is signalN, where N is the input port number. This option is useful when you are defining a signal bus from which individual signals can be extracted by using the Bus Selector block.

If you define the Number of inputs parameter as a scalar, Simulink determines the input widths by checking the output ports of the blocks feeding the Mux block. If any input is a vector, all of its elements are combined by the block.

If it is necessary to define input widths explicitly, you can specify them as a vector. Include elements with -1 values for those inputs whose widths are to be determined dynamically (during the simulation). If an input signal width does not match the expected width, Simulink displays an error message.

For example, [4 1 2] indicates three inputs forming a seven-element output vector: the first four output elements are from the first input, the fifth element comes from the second input, and the sixth and seventh elements come from the third input. If it is not important that these inputs have fixed widths, you could specify the Number of inputs as 3.

To specify three inputs where the first input vector must have four elements, you could specify [4 -1 -1]. Simulink determines the widths of the second and third inputs and sizes the output width accordingly.

Simulink draws the Mux block with the specified number of inputs. If you change the number of input ports, Simulink adds or removes them from the bottom of the block icon.

Using a Variable to Provide the Number of Inputs Parameter

When you specify the Number of inputs parameter as a variable, Simulink issues an error message if the variable is undefined in the workspace.

Note
Simulink hides the name of a Mux block when you copy it from the Simulink block library to a model.

Data Type Support

A Mux block accepts real or complex signals of any data type, including mixed-type vectors.

Parameters and Dialog Box

Number of inputs
The number and width of inputs. The width of the output line equals the sum of the widths of the input lines. You can enter a comma-separated list of signal names for this parameter field when the Display option parameter is names.
Display option
The appearance of the block icon in your model.

Display Option
Appearance of Block in Model
none
Mux appears inside block icon
names
Displays signal names next to each port
bar
Displays the block icon in a solid foreground color


[ Previous | Help Desk | Next ]