Concatenate arrays
C = cat(
concatenates dim
,A1,A2,…,An
)A1
, A2
, … , An
along
dimension dim
.
You can use the square bracket operator []
to concatenate. For
example, [A,B]
or [A B]
concatenates arrays
A
and B
horizontally, and [A; B]
concatenates them vertically.
When concatenating an empty array to a nonempty array, cat
omits the
empty array in the output. For example, cat(2,[1 2],[])
returns the row
vector [1 2]
.
If all input arguments are empty and have compatible sizes, then cat
returns an empty array whose size is equal to the output size as when the inputs are nonempty.
For example, cat(2,zeros(0,1),zeros(0,2))
returns a 0-by-3 empty
array.