Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Mux

Combine several input signals into vector

Library

Signal Routing

Description

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 Port Location After Rotating or Flipping 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:   To create a composite sig nal in which the constituent signals can have different data and numeric types, use a Bus Creator block.

Data Type Support

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.

Parameters

Number of inputs

Specify number of inputs. You can also specify the size of inputs and the names of input signals.

Settings

Default: 2

You can enter a number or a comma-separated list of signal names for this parameter field.

Use the Number of inputs parameter to specify the number of input signals. You can also specify names and sizes. Use one of these formats.

FormatBlock 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 has two inputs, named position and velocity.

    Tip:   If you specify a scalar for the Number of inputs parameter and all of the input ports are connected, as you draw a new signal line close to input side of a Mux block, Simulink adds a port and updates the Number of inputs parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Display option

Specify the appearance of the block in the model.

Settings

Default: bar

bar

Displays the block in a solid foreground color

none

Mux appears inside the block

signals

Displays signal names next to each port

Command-Line Information

See Block-Specific Parameters for the command-line information.

Examples

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

Characteristics

Data types

Double | Single | Boolean | Base Integer | Fixed-Point | Enumerated

Multidimensional signals

No

Variable-size signals

No

Code generation

Yes

See Also

Demux

Introduced before R2006a

Was this topic helpful?