Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

라이선스가 부여된 사용자만 번역 문서를 볼 수 있습니다. 번역 문서를 보려면 로그인하십시오.

cat

Concatenate arrays along specified dimension

Syntax

C = cat(dim, A, B)
C = cat(dim, A1, A2, A3, A4, ...)

Description

C = cat(dim, A, B)concatenates the arrays A and B along array the dimension specified by dim. The dim argument must be a real, positive, integer value.

C = cat(dim, A1, A2, A3, A4, ...) concatenates all the input arrays (A1, A2, A3, A4, and so on) along array dimension dim.

For nonempty arrays, cat(2, A, B) is the same as [A, B], and cat(1, A, B) is the same as [A; B].

If your input arrays are tables or timetables, dim must be either 1 or 2. cat then concatenates by calling horzcat or vertcat respectively.

Examples

Given

A =               B =
     1     2                   5     6
     3     4                   7     8

concatenating along different dimensions produces

The commands

A = magic(3); B = pascal(3);
C = cat(4, A, B);

produce a 3-by-3-by-1-by-2 array.

More About

collapse all

Tall Array Support

This function supports tall arrays with the limitation:

Concatenation in the tall dimension (dimension one) is not supported.

For more information, see Tall Arrays.

Tips

When used with comma-separated list syntax, cat(dim, C{:}) or cat(dim, C.field) is a convenient way to concatenate a cell or structure array containing numeric matrices into a single matrix.

You can concatenate categorical arrays with cell arrays of character vectors. For more information, 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 vectors.

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

Introduced before R2006a

Was this topic helpful?