rem函数和mod函数很相似,二者认真看一个,另一个看一下区别即可。
mod函数介绍:【 MATLAB 】mod 函数介绍
rem
Remainder after division
Syntax
r = rem(a,b)
Description
r = rem(
returns the remainder after division of a
,b
)a
by b
, where a
is the dividend and b
is the divisor. This function is often called the remainder operation, which can be expressed asr = a - b.*fix(a./b)
. The rem
function follows the convention that rem(a,0)
is NaN
.
a/b之后的余数便是r。如果除数为0,则rem(a,0)为NaN,这和我们的认知也很符合。
Remainder After Division of Scalar
Co