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.

Demux

Extract and output elements of vector signal

Library

Signal Routing

Description

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 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 Demux block when you copy it from the Simulink library to a model. See Mux Signals for information about creating and decomposing vectors.

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.

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

Specify the Number of Outputs

The Number of outputs parameter value can be a scalar specifying the number of outputs or a vector whose elements specify the widths of the block 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 ValueBlock 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.

An array that has one or more of m elements with a value of -1, which specifies that Simulink infers the size for the element.

For example, suppose that you have a four-element array with a total width of 14 and you specify the parameter to be [p1 p2 -1 p4].

The value for the third element (the -1 element) is 14 - (p1 + p2 + p4)

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 computed dynamically.

[p1 p2 ... pm]

p1+p2+...+pm!=n

pi = > 0

Error

 

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. For example:

You can use –1 in a vector expression to indicate that the block dynamically sizes the corresponding port. For example, the expression [-1, 3 -1] causes the block to output three signals where the second signal always has three elements. 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. The block distributes the remaining 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.

Data Type Support

The Demux block accepts and outputs complex or real signals of any nonbus 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 outputs

Specify the number or number and dimensions of outputs. For details, see Specify the Number of Outputs.

Settings

Default: 2

Specify a scalar for the number of outputs or a vector whose elements specify the widths of the block output ports.

Command-Line Information

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

See Also

Mux

Display option

Select options to display the Demux block. The options are

Settings

Default: bar

bar

Display the icon as a solid bar of the block foreground color.

none

Display the icon as a box containing the block type name.

Command-Line Information

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

See Also

See the Demux block reference page for more information.

Characteristics

Data types

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

Multidimensional signals

No

Variable-size signals

No

Code Generation

Yes

See Also

Mux

Introduced before R2006a

Was this topic helpful?