主要内容

cat

Concatenate fi arrays

Since R2026a

    Description

    C= cat(dim,A,B) concatenates B to the end of A along the dimension dim when A and B are fi arrays with compatible sizes (the lengths of the dimensions match except for the operating dimension dim). The concatenated result is a fi object.

    You can use the square bracket operator [] to concatenate or append arrays. For example, [A,B] and [A B] concatenates arrays A and B horizontally, and [A; B] concatenates them vertically.

    The fimath and numerictype objects of a concatenated matrix of fi objects C are taken from the first input, A.

    example

    C = cat(dim,A1,A2,…,An) concatenates A1, A2, … , An along dimension dim, where A1, A2,…,An are fi arrays.

    The fimath and numerictype objects of a concatenated matrix of fi objects C are taken from the leftmost fi object in the list A1,A2,…An.

    You can use comma-separated list syntax to concatenate a cell or structure array containing numeric arrays into a single array. For example,

    • cat(dim, D{:})where D is a cell array where each cells contains a numeric array.

    • cat(dim,D.field) where D is a structure array and each element of the field field contains a numeric array.

    example

    Examples

    collapse all

    Concatenate two matrices vertically, then horizontally.

    Create two matrices using fixed-point data types, and vertically append the second matrix to the first.

    a = fi([], 1, 8, 0);
    A = ones(3,3,'like',a)
    A = 
         1     1     1
         1     1     1
         1     1     1
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 8
            FractionLength: 0
    
    b = fi([], 0, 8, 2);
    B = zeros(3, 3, 'like', b)
    B = 
         0     0     0
         0     0     0
         0     0     0
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Unsigned
                WordLength: 8
            FractionLength: 2
    
    C1 = cat(1,A,B)
    C1 = 
         1     1     1
         1     1     1
         1     1     1
         0     0     0
         0     0     0
         0     0     0
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 8
            FractionLength: 0
    

    Now, horizontally append the second matrix to the first.

    C2 = cat(2,B,A)
    C2 = 
         0     0     0     1     1     1
         0     0     0     1     1     1
         0     0     0     1     1     1
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Unsigned
                WordLength: 8
            FractionLength: 2
    

    In each operation, the fixed-point data type of the first array is preserved.

    Create three matrices using fixed-point data types and concatenate the matrices.

    M1 = fi([1 2; 3 4], 1, 8, 0);
    M2 = fi([5 6; 7 8], 0, 8, 0);
    M3 = fi([9 10; 11 12], 1, 8, 2);
    C = cat(1, M1, M2, M3)
    C = 
         1     2
         3     4
         5     6
         7     8
         9    10
        11    12
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 8
            FractionLength: 0
    

    Create a cell array containing the three matrices and concatenate the matrices vertically.

    A1 = {M1,M2,M3};
    Cvert = cat(1,A1{:})
    Cvert = 
         1     2
         3     4
         5     6
         7     8
         9    10
        11    12
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 8
            FractionLength: 0
    

    Create a structure array with a field f containing the three matrices and concatenate the matrices horizontally.

    s(1).f = M1;
    s(2).f = M2;
    s(3).f = M3;
    Chorz = cat(2,s.f)
    Chorz = 
         1     2     5     6     9    10
         3     4     7     8    11    12
    
              DataTypeMode: Fixed-point: binary point scaling
                Signedness: Signed
                WordLength: 8
            FractionLength: 0
    

    Input Arguments

    collapse all

    Dimension to operate along, specified as a positive integer scalar. For example, if A and B are both 2-by-2 matrices, then cat(1,A,B) concatenates vertically creating a 4-by-2 matrix. cat(2,A,B) concatenates horizontally creating a 2-by-4 matrix.

    First input, specified as a scalar, vector, matrix, or multidimensional array.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
    Complex Number Support: Yes

    Second input, specified as a scalar, vector, matrix, or multidimensional array.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
    Complex Number Support: Yes

    List of inputs, specified as a comma-separated list of elements to concatenate in the order they are specified.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
    Complex Number Support: Yes

    Version History

    Introduced in R2026a