Mux

Combine input signals of same data type and complexity into virtual vector

  • 库:
  • Simulink / Commonly Used Blocks

    Simulink / Signal Routing

    高密度脂蛋白编码器/常用的块

    HDL Coder / Signal Routing

Description

TheMuxblock combines inputs with the same data type and complexity into a vector output. The output mux signal is flat, even if you create the mux signal from other mux signals. However, you can use multipleMuxblocks to create a mux signal in stages.

A mux signal simplifies the visual appearance of a model by combining two or more signal lines into one line. Mux signals do not affect simulation or code generation.

Tip

If inputs have different data types or complexity, use a virtual bus to visually group the signals. For more information, seeTypes of Composite Signals.

Ports

Input

expand all

Input signal to include in the mux signal, specified as a scalar or vector.

The input signals for aMuxblock can be any combination of scalars and vectors, but they must have the same data type and complexity.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|Boolean|fixed point|enumerated
Complex Number Support:Yes

Output

expand all

Output mux signal composed of the combined input signals, returned as a vector.

The elements of the output mux signal take their order from the port order of the input signals. For a description of the port order for various block orientations, seePort Location After Rotating or Flipping.

Data Types:single|double|int8|int16|int32|int64|uint8|uint16|uint32|uint64|Boolean|fixed point|enumerated

Parameters

expand all

The number of input signals, specified as a scalar, vector, cell array, or comma-separated list of signal names. Some of these formats allow you to specify the signal names and sizes, as described by the following table.

Format Block Behavior

Scalar

The number of inputs to theMuxblock.

When you use this format, the block accepts scalar or vector signals of any size. Simulink®assigns each input the namesignalN, whereNis 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 sizes2and3, respectively. If an input signal width does not match the expected width, an error message appears. A value of-1specifies 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 valueNspecifies a vector of sizeN. A value of-1means that the corresponding port can accept scalar or vector signals of any size.

Comma-separated list of signal names

A list of signal names separated by commas. Simulink assigns each name to the corresponding port and signal. For example, if you enterposition,velocity,Muxblock has two inputs, namedpositionandvelocity.

Tip

If you specify a scalar for theNumber of inputsparameter and all of the input ports are connected, as you draw a new signal line close to input side of aMuxblock, Simulink adds a port and updates the parameter.

Programmatic Use

Block Parameter:Inputs
Type:scalar, vector, cell array, comma-separated list of signal names
Values:integer, vector of port sizes, cell array, comma-separated list of signal names
Default:{'2'}

Block icon appearance, specified asbar,signal, ornone.

  • bar— Displays no text

  • signal— Displays the input signal names

  • none— Displays the type of block (Mux)

Resize the block as necessary to fit the text on the block icon.

Programmatic Use

Block Parameter:DisplayOption
Type:character vector
Values:'bar''signals''none''bar'
Default:'bar'

Block Characteristics

Data Types

Boolean|double|enumerated|fixed point|integer|single

Direct Feedthrough

yes

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

PLC Code Generation
Generate Structured Text code using Simulink® PLC Coder™.

Introduced before R2006a