Re: [問題] Index must be positive interger已回收

看板MATLAB作者 ( )時間15年前 (2010/03/18 09:57), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
自問自答... The problem is that 0.1 can't be represented exactly in the binary floating point arithmetic system used by MATLAB. Perhaps the following example will help- suppose that you have a calculator that stores numbers in 12 digit decimal floating point form (this is actually quite common), and you want to multiply 3* (1/3). In the calculator, you'd get 1/3=0.333333333333 3*0.333333333333=0.999999999999 so 3*(1/3) wouldn't be exactly 1. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 76.232.9.153

03/18 09:57, , 1F
換言之 加上 round 取整數即可...
03/18 09:57, 1F
文章代碼(AID): #1BeOY5qu (MATLAB)
文章代碼(AID): #1BeOY5qu (MATLAB)