vertcat

Concatenates arrays vertically.

Category: Language Fundamentals > Matrices and Arrays

Syntax

C = vertcat(A1, A2, ...)

Stacks the arguments one below the other. Same as [A1; A2; ...].

Description

vertcat is the function behind the semicolon inside square brackets. Using the function form is convenient when the pieces are held in a cell array, since vertcat(c{:}) stacks them all.

Mixing types follows the usual concatenation rules: integers win over doubles, and char combined with numbers gives char. Empty inputs [] are ignored.

Input arguments

A1, A2, ...
Arrays with the same number of columns (and same size in all higher dimensions).

Output arguments

C
The stacked array, with as many rows as all inputs together.

Example

vertcat([1 2], [3 4], [5 6])
c = {[1 2], [3 4]};
vertcat(c{:})
Output
ans = 3×2

     1     2
     3     4
     5     6
ans = 2×2

     1     2
     3     4

See also

horzcat cat repmat