Simulink Matrix Concatenation: A Quick Reference

Matrix concatenation in Simulink is performed by the Matrix Concatenate block (found under Math Operations). The block combines multiple input matrices along a specified dimension, governed by the Concatenation method parameter: Horizontal or Vertical.


Horizontal Concatenation

Horizontal concatenation joins matrices side-by-side, appending columns. This corresponds to MATLAB’s [A, B] syntax.

Dimension rule: all input matrices must share the same number of rows. The output column count is the sum of each input’s column count.

\[[A \mid B] \quad \Longrightarrow \quad \text{rows}_A = \text{rows}_B, \quad \text{cols}_{\text{out}} = \text{cols}_A + \text{cols}_B\]

Example

Given:

\[A = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}_{2 \times 2} \qquad B = \begin{bmatrix} 5 \\ 6 \end{bmatrix}_{2 \times 1}\]

Horizontal concatenation yields:

\[[A \mid B] = \begin{bmatrix} 1 & 2 & 5 \\ 3 & 4 & 6 \end{bmatrix}_{2 \times 3}\]
A  2×2
12 34
+
B  2×1
5 6
[A | B]  2×3
1 2 5 3 4 6

Simulink block setting: set Concatenation method to Horizontal and Number of inputs to 2.


Vertical Concatenation

Vertical concatenation stacks matrices one above the other, appending rows. This corresponds to MATLAB’s [A; B] syntax.

Dimension rule: all input matrices must share the same number of columns. The output row count is the sum of each input’s row count.

\[\begin{bmatrix} A \\ B \end{bmatrix} \quad \Longrightarrow \quad \text{cols}_A = \text{cols}_B, \quad \text{rows}_{\text{out}} = \text{rows}_A + \text{rows}_B\]

Example

Given:

\[A = \begin{bmatrix} 1 & 2 & 3 \end{bmatrix}_{1 \times 3} \qquad B = \begin{bmatrix} 4 & 5 & 6 \end{bmatrix}_{1 \times 3}\]

Vertical concatenation yields:

\[\begin{bmatrix} A \\ B \end{bmatrix} = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}_{2 \times 3}\]
A  1×3
123
+
B  1×3
456
[A; B]  2×3
1 2 3 4 5 6

Simulink block setting: set Concatenation method to Vertical and Number of inputs to 2.


Summary

Property Horizontal [A, B] Vertical [A; B]
Growth direction Along columns (→) Along rows (↓)
Shared constraint Row count must match Column count must match
Output rows Same as inputs Sum of input rows
Output columns Sum of input columns Same as inputs
MATLAB equivalent [A, B] [A; B]

Common Pitfall

Simulink will throw a dimension mismatch error at simulation start if the constrained dimension is inconsistent across inputs. Check signal dimensions using Simulation → Update Diagram (Ctrl+D) before running to surface these errors early.