./
Element-wise right division operator.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
C = A ./ B
Divides each element of A by the matching element of B. Same as rdivide(A, B).
Description
Floating-point division by zero does not raise an error: 1./0 is Inf, -1./0 is -Inf and 0./0 is NaN. Sizes are expanded implicitly, so x ./ sum(x) normalizes a vector and A ./ max(A) scales each column of a matrix.
For integer types the quotient is rounded to the nearest integer and saturates; dividing by zero gives the largest value, or 0 for 0./0.
Input arguments
A- Numerator: numeric or logical array.
B- Denominator, with a size compatible with
A.
Output arguments
C- Array of quotients.
Example
[2 4 6] ./ [1 2 3]
[1 0 -1] ./ 0
x = [1 2 3 4];
x ./ sum(x)
int32(7) ./ int32(2)
Output
ans = 1×3
2 2 2
ans = 1×3
Inf NaN -Inf
ans = 1×4
0.1000 0.2000 0.3000 0.4000
ans = int32
4