Concatenate arrays horizontally
C = horzcat(
concatenates
A1,A2,…,An
)A1
, A2
, … , An
horizontally.
horzcat
is equivalent to using square brackets for horizontally
concatenating arrays. For example, [A,B]
or [A B]
is
equal to horzcat(A,B)
when A
and B
are compatible arrays.
For table inputs, horzcat
concatenates by matching row names when
present, or by matching table positions. horzcat
assigns values for the
Description
and UserData
properties of the output
using the first nonempty values of the corresponding properties of the input.
When concatenating an empty array to a nonempty array, horzcat
omits
the empty array in the output. For example, horzcat([1 2],[])
returns the
row vector [1 2]
.
If all input arguments are empty and have compatible sizes, then
horzcat
returns an empty array whose size is equal to the output size as
when the inputs are nonempty. For example, horzcat(zeros(0,1),zeros(0,2))
returns a 0-by-3 empty array. If the input sizes are not compatible, then
horzcat
returns a 0-by-0 empty array.