Arithmetic Operations

本文重点介绍基本数学运算__函数__, 关于__运算符__实现的基本运算见 Matlab Matrix OperationsMatlab Array Operations.

Modulo division

  • mod 取余数
    • mod(a,m) returns the remainder after division of a by m
    • = a - m.*floor(a./m)
    • mod(a,0) returns a
  • rem 取余数
    • rem(a,m) returns the remainder after division of a by m
    • = a - m.*fix(a./m)
    • rem(a,0) returns NaN
  • idivide 取整数
    • idivide(a,b,<opt>) 返回按 opt 取整后的 a/b
    • opt 默认为 'fix', 可选 'fix', 'floor', 'ceil', 'round'

Rounding

  • round rounds half up away from 0
  • fix rounds towards 0
  • floor rounds towards negative infinity
  • ceil rounds towards positive infinity