plus
Function form of the addition operator +.
Category: Language Fundamentals > Data Types
Syntax
C = plus(A, B)
Adds A and B element by element. Same as A + B.
Description
plus(A, B) is exactly what the + operator calls. It is useful where a function handle is needed, as in arrayfun(@plus, a, b), and it is the name a class overloads to define addition for its own objects.
Implicit expansion applies: a column plus a row gives a matrix. Integer types saturate rather than wrap around.
Input arguments
A, B- Numeric, logical or char arrays, duration or datetime values, or objects that define
plus. Sizes must be compatible.
Output arguments
C- The sum, with the size produced by implicit expansion.
Example
plus(1, 2)
plus([1 2], [10; 20])
plus(int8(100), int8(100))
Output
ans = 3
ans = 2×2
11 12
21 22
ans = int8
127