matlab 中mod的用法
答案:1 悬赏:80 手机版
解决时间 2021-02-23 03:40
- 提问者网友:饥饿走向夜
- 2021-02-22 06:06
matlab 中mod的用法
最佳答案
- 五星知识达人网友:撞了怀
- 2021-02-22 07:13
简单的说mod(a,b)就是求的是a除以b的余数。比方说mod(100,3)=1,mod(17,6)=5
详细用法见下
mod
Modulus after division
Syntax
M = mod(X,Y)
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. The inputs X and Y must be real arrays of the same size, or real scalars.
The following are true by convention: mod(X,0) is X mod(X,X) is 0 mod(X,Y) for X~=Y and Y~=0 has the same sign as Y.
Remarks
rem(X,Y) for X~=Y and Y~=0 has the same sign as X.
mod(X,Y) and rem(X,Y) are equal if X and Y have the same sign, but differ by Y if X and Y have different signs.
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).
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
详细用法见下
mod
Modulus after division
Syntax
M = mod(X,Y)
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. The inputs X and Y must be real arrays of the same size, or real scalars.
The following are true by convention: mod(X,0) is X mod(X,X) is 0 mod(X,Y) for X~=Y and Y~=0 has the same sign as Y.
Remarks
rem(X,Y) for X~=Y and Y~=0 has the same sign as X.
mod(X,Y) and rem(X,Y) are equal if X and Y have the same sign, but differ by Y if X and Y have different signs.
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).
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
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯