Accelerating the pace of engineering and science

# Documentation Center

• Trials
• Product Updates

# plus, +

## Description

example

C = A + B adds arrays A and B and returns the result in C.

C = plus(A,B) is an alternate way to execute A + B, but is rarely used. It enables operator overloading for classes.

## Examples

expand all

### Add Scalar to Array

Create an array, A, and add a scalar value to it.

```A = [0 1; 1 0];
C = A + 2```
```C =

2     3
3     2```

The scalar value is added to each entry of A.

### Add Two Arrays

Create two arrays, A and B, and add them together.

```A = [1 0; 2 4];
B = [5 9; 2 1];
C = A + B```
```C =

6     9
4     5```

The elements of A are added to the corresponding elements of B.

## Input Arguments

expand all

### A — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array. Inputs A and B must be the same size unless one is a scalar. You can add a scalar value to any other value.

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

### B — Input arrayscalar | vector | matrix | multidimensional array

Input array, specified as a scalar, vector, matrix, or multidimensional array. Inputs A and B must be the same size unless one is a scalar. You can add a scalar value to any other value.

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

## See Also

Was this topic helpful?