Concatenate arrays vertically
C = vertcat(A1,...,AN)
C = vertcat(A1,...,AN)
vertically
concatenates arrays A1,...,AN
. All arrays in the
argument list must have the same number of columns.
If the inputs are multidimensional arrays, vertcat
concatenates
N-dimensional arrays along the first dimension. The remaining dimensions
must match.
If the inputs are tables, vertcat
concatenates
by matching variable names. Variable names for all tables must be
identical, except for order. Row names, when present, must be unique
across tables.
vertcat
fills in default row names when
some of the inputs have names and some do not. vertcat
assigns
values for each table property (except for RowNames
)
using the first nonempty value for the corresponding property in the
tables A1,...,AN
.
If the inputs are timetables, then column names must be the same.
vertcat
also concatenates character arrays.
Each array being concatenated must have the same number of characters.
MATLAB® calls C = vertcat(A1, A2, ...)
for
the syntax C = [A1; A2; ...]
when any of the inputs
are an object.
To concatenate categorical arrays, see Combine Categorical Arrays.
If all the input arrays are ordinal categorical arrays, they must have the same sets of categories including their order. For more information, see Ordinal Categorical Arrays.
You can concatenate datetime arrays with cell arrays of character arrays.
You can concatenate duration arrays and calendar duration arrays. The result is a calendar duration array.
You can concatenate duration or calendar duration arrays with
numeric arrays. Prior to concatenation, MATLAB converts the numeric
array to an array of equivalent days using the days
function.
You can concatenate string arrays with numeric arrays, logical arrays, character vectors, or cell arrays. The non-string arrays are first converted to a string array, and the output is returned as a string array.
For information on combining unlike integer types, integers with nonintegers, cell arrays with non-cell arrays, or empty matrices with other elements, see Valid Combinations of Unlike Classes.