Matlab Data Precision Problem
I have created a simple computation using Matlab using command :
>> (0.1450-0.002)/0.002 ans = 71.5000
Nothing wrong with the result. But, try to change data precision format and try to retype command above. we will get Matlab data precision problem from this simple computation.
>> format long >> (0.1450-0.002)/0.002 ans = 71.499999999999986
We get the wrong result. I hope can get 71.5000 from above command. This precision can be bigger problem if we use the result to create a variable for next computation like below :
>> format long >> ndata = round((0.1450-0.002)/0.002) ndata = 71
Manual computation will get result 72.
I dont know why Matlab can not solve this simple computation with the right precision (Matlab Data Precision Problem). Sometime, we need to add a variable like 0.5 to get the right result.
I am testing this computation using Matlab 2013a and Matlab 2015a ad still get the same result (Matlab data precision problem). I hope Matlab can solve this problem in the next release.