# plus, +

Matrix sum of `fi`

objects

## Syntax

## Description

is an alternate way to execute `C`

= plus(`A`

,`B`

)`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

### Use Implicit Expansion to Add Vectors, Matrices, and Multidimensional Arrays

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

`A`

— Input array

scalar | vector | matrix | multidimensional array

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

`B`

— Input array

scalar | vector | matrix | multidimensional array

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

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

Usage notes and limitations:

Any non-

`fi`

inputs must be constant; that is, its value must be known at compile time so that it can be cast to a`fi`

object.

### HDL Code Generation

Generate VHDL, Verilog and SystemVerilog code for FPGA and ASIC designs using HDL Coder™.

Inputs cannot be of data type `logical`

.

## Version History

**Introduced before R2006a**

### R2021b: Implicit expansion change affects arguments for operators

Starting in R2021b with the addition of implicit expansion for `fi`

`times`

, `plus`

, and `minus`

, some
combinations of arguments for basic operations that previously returned errors now produce
results.

If your code uses element-wise operators and relies on the errors that MATLAB^{®} previously returned for mismatched sizes, particularly within a
`try/catch`

block, then your code might no longer catch those
errors.

For more information on the required input sizes for basic array operations, see Compatible Array Sizes for Basic Operations.

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)