Matlab Array - Concatenating

  • All operations below return a new array.

General Concatenation

  • Each input array’s size must match the chosen concatenation axis, otherwise an error is raised.

  • Horizontal concatenation

    • [A1 A2 ...]
    • Function horzcat(A1,A2,...)
  • Vertical concatenation

    • [A1; A2; ...]
    • Function vertcat(A1,A2,...)
  • Concatenation along an arbitrary dimension

    • Function cat(dim,A1,A2,...) concatenates A1, …, An along dimension dim
      • dim may exceed the input arrays’ dimensionality, in which case a higher-dimensional array is created; any unspecified intermediate dimensions are filled with size 1
  • Horizontal concatenation corresponds to dim = 2, and vertical concatenation to dim = 1.

Block Operations

The functions below take matrices as inputs and treat them as building blocks of a larger array: