horzcat
Concatenate arrays horizontally
Description
C = horzcat(
concatenates
A1,A2,…,An
)A1
, A2
, … , An
horizontally.
horzcat
is equivalent to using square brackets to horizontally
concatenate or append arrays. For example, [A,B]
and [A
B]
is the same as horzcat(A,B)
when A
and
B
are compatible arrays.
Examples
Input Arguments
Tips
Algorithms
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.
Extended Capabilities
Version History
Introduced before R2006a