mod

Returns x modulo y.

Syntax

R = mod(x, y)

Inputs

x
Dividend.
Type: double
Dimension: scalar | vector | matrix
y
Divisor.
Type: double
Dimension: scalar | vector | matrix

Outputs

R
Remainder.
Type: double
Dimension: scalar | vector | matrix

Examples

Simple scalar input:
R = mod(-1, 3)
R = mod(15, -5)
R = 2
R = 0
Scalar matrix input:
R = mod(10, [4,-3])
R = mod([10,15], -6)
R = [ 2 -2 ]
R = [ -2 -3 ]
Matrix input:
R = mod([10,15], [7, 4])
R = [ 3 3 ]

Comments

mod(x, y) function computes x - y .* floor(x ./ y)