[心得]Matlab mod function之誤差
a mod b = 0, but a/b卻不整除
發生在b不是整數且b的倍數非常接近a時
ex: a=-2.3561944901923453,b=0.0087266462599716477
mod(a,b)=0, a/b=-270.00000000000006
Matlab的help裡也有說了
MOD(x,y) is x - n.*y where n = floor(x./y) if y ~= 0. If y is not an
integer and the quotient x./y is within roundoff error of an integer,
then n is that integer.
也就是會有誤差,希望有用到mod寫程式的可以注意一下
找出這問題找了半天.....
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.120.14.167
→
12/07 15:02, , 1F
12/07 15:02, 1F
推
03/22 20:13, , 2F
03/22 20:13, 2F
→
03/22 20:13, , 3F
03/22 20:13, 3F
MATLAB 近期熱門文章
PTT數位生活區 即時熱門文章
0
18