minus

Subtraction, the function form of the operator -.

Category: Symbolic Computations in MATLAB > Operators and Elementary Operations

Syntax

C = minus(A, B)

Same as A - B.

C = minus(A, B, C, ...)

Subtracts the later arguments from the first, from left to right.

Description

The subtraction is elementwise and follows implicit expansion: a scalar is subtracted from every element, and a row minus a column gives a matrix. For matrices of equal size it is the ordinary matrix difference.

Integer types saturate instead of wrapping: minus(uint8(3), 5) is 0 and minus(int8(100), int8(-100)) is 127. An integer cannot be combined with a different integer type.

Input arguments

A, B
Numeric, logical, datetime or symbolic operands with compatible sizes.

Output arguments

C
Difference, with the size given by implicit expansion.

Example

Expansion and saturation

minus([1 2 3], 1)
minus([1 2 3], [1; 2])
minus(uint8(3), 5)
Output
ans = 1×3

     0     1     2
ans = 2×3

     0     1     2
    -1     0     1
ans = uint8
   0

See also

plus uminus times diff