| Simulink® | ![]() |
Signal Routing
The Demux block extracts the components of an input signal and outputs the components as separate signals. The output signals are ordered from top to bottom output port. (See Changing the Orientation of a Blockin the Simulink® documentation 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.
The Number of outputs parameter allows you to specify the number and, optionally, the dimensionality of each output port. If you do not specify the dimensionality of the outputs, the block determines the dimensionality of the outputs for you.
The Demux block operates in either vector mode or bus selection mode, depending on whether you selected the Bus selection mode parameter. The two modes differ in the types of signals they accept. Vector mode accepts only a vector-like signal, that is, either a scalar (one-element array), vector (1-D array), or a column or row vector (one row or one column 2-D array). Bus selection mode accepts only the output of a Mux block or another Demux block.
Note The MathWorks discourages enabling Bus selection mode and using a Demux block to extract elements of a bus signal. Muxes and buses should not be intermixed in new models. See Intermixing Composite Signal Types for details. |
The Demux block's Number of outputs parameter determines the number and dimensionality of the block's outputs, depending on the mode in which the block operates.
In vector mode, the value of the parameter can be a scalar specifying the number of outputs or a vector whose elements specify the widths of the block's output ports. The block determines the size of its outputs from the size of the input signal and the value of the Number of outputs parameter.
The following table summarizes how the block determines the outputs for an input vector of width n.
| Parameter Value | Block outputs... | Comments |
|---|---|---|
p = n | p scalar signals | For example, if the input is a three-element vector and you specify three outputs, the block outputs three scalar signals. |
p > n | Error | |
p < n n mod p = 0 | p vector signals each having n/p elements | If the input is a six-element vector and you specify three outputs, the block outputs three two-element vectors. |
p < n n mod p = m | m vector signals each having (n/p)+1 elements and p-m signals having n/p elements | If the input is a five-element vector and you specify three outputs, the block outputs two two-element vector signals and one scalar signal. |
[p1 p2 ... pm] p1+p2+...+pm=n pi > 0 | m vector signals having widths p1, p2, ... pm | If the input is a five-element vector and you specify [3, 2] as the output, the block outputs three of the input elements on one port and the other two elements on the other port. |
[p1 p2 ... pm] p1+p2+...+pm=n some or all pi = -1 | m vector signals | If pi is greater than zero, the corresponding output has width pi. If pi is -1, the width of the corresponding output is dynamically sized. |
[p1 p2 ... pm] p1+p2+...+pm!=n pi = > 0 | Error |
Note that you can specify the number of outputs as fewer than the number of input elements, in which case the block distributes the elements as evenly as possible over the outputs as illustrated in the following example.

You can use -1 in a vector expression to indicate that the block should dynamically size the corresponding port. For example, the expression [-1, 3 -1] causes the block to output three signals in which the second signal always has three elements while the sizes of the first and third signals depend on the size of the input signal.
If a vector expression comprises positive values and -1 values, the block assigns as many elements as needed to the ports with positive values and distributes the remain elements as evenly as possible over the ports with -1 values. For example, suppose that the block input is seven elements wide and you specify the output as [-1, 3 -1]. In this case, the block outputs two elements on the first port, three elements on the second, and two elements on the third.

In bus selection mode, the value of the Number of outputs parameter can be a
Scalar specifying the number of output ports
The specified value must equal the number of input signals. For example, if the input bus comprises two signals and the value of this parameter is a scalar, the value must equal 2.

Vector each of whose elements specifies the number of signals to output on the corresponding port
For example, if the input bus contains five signals, you can specify the output as [3, 2], in which case the block outputs three of the input signals on one port and the other two signals on a second port.
Cell array each of whose elements is a cell array of vectors specifying the dimensions of the signals output by the corresponding port
The cell array format constrains the Demux block to accept only signals of specified dimensions. For example, the cell array {{[2 2], 3} {1}} tells the block to accept only a bus signal comprising a 2-by-2 matrix, a three-element vector, and a scalar signal. You can use the value -1 in a cell array expression to let the block determine the dimensionality of a particular output based on the input. For example, the following diagram uses the cell array expression {{-1}, {-1,-1}} to specify the output of the leftmost Demux block.

In bus selection mode, if you specify the dimensionality of an output port, i.e., if you specify any value other than -1, the corresponding input element must match the specified dimensionality.
Note The MathWorks discourages enabling Bus selection mode and using a Demux block to extract elements of a bus signal. Muxes and buses should not be intermixed in new models. See Intermixing Composite Signal Types for details. |
The Demux block accepts and outputs complex or real signals of any data type supported by Simulink software, including fixed-point data types.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink®.

The number and dimensions of outputs.
Options for displaying the Demux block. The options are
| Option | Description | Example |
|---|---|---|
bar | Display the icon as a solid bar of the block's foreground color. |
|
none | Display the icon as a box containing the block's type name. |
|
Enable bus selection mode.
Note The MathWorks discourages enabling Bus selection mode and using a Demux block to extract elements of a bus signal. Muxes and buses should not be intermixed in new models. See Intermixing Composite Signal Types for details. |
![]() | Decrement To Zero | Derivative | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |