痒痒挠 发表于 2006-6-4 16:32

[求助]rem和mod有什么区别,谢谢各位大虾

谢谢谢谢<br>我知道二者有区别,但是到底区别在哪却不大清楚。<br>哪位大虾可以给小弟解释一下,感激不尽
[此贴子已经被cdwxg于2006-6-4 17:18:18编辑过]

cdwxg 发表于 2006-6-4 17:17

<P><FONT color=#ff0000>R = rem(X,Y)</FONT> if Y ~= 0, returns X - n.*Y where n = fix(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, <FONT color=#0000ff>rem(X,0) is NaN</FONT>. The inputs X and Y must be real arrays of the same size, or real scalars<br><br><FONT color=#ff0000>M = mod(X,Y)</FONT> 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, <FONT color=#0000ff>mod(X,0) is X.</FONT> The inputs X and Y must be real arrays of the same size, or real scalars<br><br><br><FONT color=#ff0000>So long as operands X and Y are of the same sign, the statement rem(X,Y) returns the same result as does mod(X,Y). <br></FONT><FONT color=#0000ff>However, for positive X and Y, rem(-X,Y) = mod(-X,Y)-Y<br>也就是说除了特定的几个用途外,只有正负时候的转化有区别。<br></FONT></P>
<P>The <FONT color=#ff0000>rem</FONT> function returns a result that is between 0 and sign(X)*abs(Y). If Y is zero, rem returns NaN.<br>The <FONT color=#ff0000>mod</FONT> function is useful for congruence relationships: x and y are congruent (mod m) if and only if mod(x,m) == mod(y,m).<br>对于平常用的常数类或者常数矩阵基本没有区别。</P>
[此贴子已经被作者于2006-6-4 17:26:02编辑过]

痒痒挠 发表于 2006-6-4 17:55

谢谢哈
页: [1]
查看完整版本: [求助]rem和mod有什么区别,谢谢各位大虾