Main Content

plus, +

Matrix sum of fi objects

Description

C = A+B adds the matrix A to matrix A.

plus does not support fi objects of data type boolean.

example

C = plus(A,B) is an alternate way to execute A+B.

Note

For information about the fimath properties involved in Fixed-Point Designer™ calculations, see fimath Properties Usage for Fixed-Point Arithmetic and fimath ProductMode and SumMode.

Examples

collapse all

This example shows how to use implicit expansion to add vectors and matrices with compatible dimensions.

Add Row and Column Vectors

Create a 3-by-1 column vector and 1-by-5 row vector and add them.

x = fi([1;2;3]);
y = fi([1,2,3,4,5]);
z = x + y
z = 
     2     3     4     5     6
     3     4     5     6     7
     4     5     6     7     8

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 18
        FractionLength: 13

The result is a 3-by-5 matrix, where each (i,j) element in the matrix is given by z(i,j) = x(i) + y(j).

Add Matrix and Column Vector

Create an M-by-N matrix and a M-by-1 column vector and add them.

x = fi([1 2 3 4 5 
        6 7 8 9 10 
        11 12 13 14 15]);
y = fi([1;2;3]);
z = x + y
z = 
     2     3     4     5     6
     8     9    10    11    12
    14    15    16    17    18

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 19
        FractionLength: 13

The result is an M-by-N matrix, where each (i,j) element in the matrix is given by z(i,j) = x(i,j) + y(i).

Add Matrix and Row Vector

Create a M-by-N matrix and a 1-by-N row vector and add them.

x = fi([1 2 3 4 5 
        6 7 8 9 10 
        11 12 13 14 15]);
y = fi([1 2 3 4 5]);
z = x + y
z = 
     2     4     6     8    10
     7     9    11    13    15
    12    14    16    18    20

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 18
        FractionLength: 12

The result is an M-by-N matrix, where each (i,j) element in the matrix is given by z(i,j) = x(i,j) + y(j).

Add Matrix to Multidimensional Array

Create a M-by-N matrix and a M-by-N-by-P array and add them.

x = fi(ones(3,5));
y = fi(ones(3,5,3));
z = x + y
z = 
(:,:,1) =
     2     2     2     2     2
     2     2     2     2     2
     2     2     2     2     2
(:,:,2) =
     2     2     2     2     2
     2     2     2     2     2
     2     2     2     2     2
(:,:,3) =
     2     2     2     2     2
     2     2     2     2     2
     2     2     2     2     2

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 17
        FractionLength: 14

The result is an M-by-N-by-P array, where each (i,j,k) element in the array is given by z(i,j,k) = x(i,j) + y(i,j,k).

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array of fi objects or built-in data types. Inputs A and B must either be the same size or have sizes that are compatible. For more information, see Compatible Array Sizes for Basic Operations.

plus does not support fi objects of data type boolean.

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

Input array, specified as a scalar, vector, matrix, or multidimensional array of fi objects or built-in data types. Inputs A and B must either be the same size or have sizes that are compatible. For more information, see Compatible Array Sizes for Basic Operations.

plus does not support fi objects of data type boolean.

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

Compatibility Considerations

expand all

Behavior changed in R2021b

Extended Capabilities

See Also

| | |

Introduced before R2006a