[心得]Matlab mod function之誤差

看板MATLAB作者 (wu0w u0w )時間18年前 (2005/12/07 13:49), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
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
Matlab很多函式都有數值計算的問題,ex:算eigenvalue
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
文章代碼(AID): #13bdW1k7 (MATLAB)
文章代碼(AID): #13bdW1k7 (MATLAB)