mod 函数

mod 函数

Modulus after division

余数(除法运算后的系数或称为有符号取余)

Syntax

语法

M = mod(X,Y)

Definition

定义

mod(x,y) is mod .

Description

描述

M = mod(X,Y) if Y ~= 0, returns X - n.*Y where n = floor(X./Y) . If Y is not an integer and the quotient X./Y is within roundoff error of an integer, then n is that integer. By convention, mod(X,0) is X. The inputs X and Y must be real arrays of the same size, or real scalars.

M=mod(X,Y)如果Y~=0,返回X-n.*y这里的n=floor(X./Y)。如果Y不是一个整数并且商X./Y是一个整数的内部错误,之后n是整数。通过被约束,mod(X,0)X。输出的XY必须是相同大小的实数阵列,或是实数数量。

Remarks

备注

So long as operands X and Y are of the same sign, the function mod(X,Y) returns the same result as does rem(X,Y). However, for positive X and Y,

再次遇到具有相同迹象的操作数XY,函数mod(X,Y)返回相同的结果为rem(X,Y)。无论如何,正数XY

mod(-X,Y) = rem(-X,Y)+Y

The mod function is useful for congruence relationships: x and y are congruent (mod m) if and only if mod(x,m) == mod(y,m).

mod函数对一致关系是很有用处的:xy是一致(mod m)如果并且仅仅如果mod(x,m)=mod(y,m)

Examples

例如:

mod(13,5)

ans =

     3

mod([1:5],3)

ans =

     1     2     0     1     2 

mod(magic(3),3)

ans =

     2     1     0

     0     2     1

     1     0     2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值