| Simulink® | ![]() |
Signal Routing

The Merge block combines its inputs into a single output line whose value at any time is equal to the most recently computed output of its driving blocks. You can specify any number of inputs by setting the block's Number of inputs parameter.
Note Merge blocks assume that all driving signals share the same signal memory. The shared signal memory should be accessed only in mutually exclusive fashion. Therefore, always use alternately executing subsystems to drive Merge blocks. See Creating Alternately Executing Subsystems for an application example. |
A Merge block does not accept signals whose elements have been reordered or partially selected. For example, in the following diagram, the Merge block does not accept the output of the first Selector block because the Selector block interchanges the first and last elements of the vector signal. It does not accept the output of the second Selector block because the Selector block selects only the first three elements.

If the Allow unequal port widths parameter is not selected, the block accepts only inputs of equal dimensions and outputs a signal of the same dimensions as the inputs. If you select the Allow unequal port widths option, the block accepts scalars and vectors (but not matrices) having differing numbers of elements. Further, the block allows you to specify an offset for each input signal relative to the beginning of the output signal. The width of the output signal is
max(w1+o1, w2+o2, ... wn+on)
where w1, ... wn are the widths of the input signals and o1, ... on are the offsets for the input signals. For example, the Merge block in the following diagram has a Merge block width of
max(2+0,2+1)=3

In this example, the offset of v1 is 0 and the offset of v2 is 1. The Merge block maps the elements of v1 to the first two elements of v3 and the elements of v2 to the last two elements of v3. Only the second element of v3 is effectively merged, as seen from the scopes output.
You can specify an initial output value by setting the block's Initial output parameter. If you do not specify an initial output and one or more of the driving blocks do, the Merge block's initial output equals the most recently evaluated initial output of the driving blocks.
The Merge block can merge a signal from an S-Function block only if the memory used to store the S-Function block's output is reusable. Simulink® software displays an error message if you attempt to update or simulate a model that connects a nonreusable port of an S-Function block to a Merge block. See ssSetOutputPortOptimOpts for more information.
When using the Merge block, consider the following:
Do not connect an input of a Merge block to any other block. Doing so causes an error.
Always use conditionally executed subsystems to drive Merge blocks.
Always set the Initial output parameter of the Merge block.
Write your control logic to ensure that at most one of the driving conditionally executed subsystems executes at any time step.
Note Where possible, use the If or Switch Case block to provide control logic. |
For all conditionally executed subsystem Outport blocks that drive Merge blocks:
Set the Initial output parameter to empty matrix ([]).
Set the Output when disabled parameter to held.
The Merge block accepts real or complex signals of any data type supported by Simulink software, including fixed-point data types. All inputs must be of the same data type and numeric type.
For a discussion on the data types supported by Simulink software, see Data Types Supported by Simulink® in the Simulink documentation.

The number of input ports to merge.
Initial value of output. If unspecified, the initial output equals the initial output, if any, of one of the driving blocks. Simulink software does not allow you to set the initial output of this block to inf or NaN.
Allows the block to accept inputs having different numbers of elements.
Vector specifying the offset of each input signal relative to the beginning of the output signal.
The Merge block is a bus-capable block. The inputs can be virtual or nonvirtual bus signals subject to the following restrictions:
The number of inputs must be greater than one.
Initial output must be zero or a nonzero scalar.
Allow unequal port widths must be disabled.
All inputs to the merge must be buses and must be equivalent (same hierarchy with identical names and attributes for all elements).
| Bus-capable | Yes, with restrictions as noted above |
Direct Feedthrough | Yes |
Sample Time | Inherited from the driving block |
Scalar Expansion | No |
Dimensionalized | Yes |
Multidimensionalized | Yes |
Zero Crossing | No |
![]() | Memory | MinMax | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |