increasing the accuracy of the matlab

Status
Not open for further replies.

pankaj jha

Full Member level 3
Joined
Apr 16, 2010
Messages
170
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Location
jaipur
Visit site
Activity points
2,457
hello everyone!!

I have text file with data as such:
------------------------------
0.01 0.900130876
0.02 0.900425071
0.03 0.899321801
0.04 0.946314084
0.05 1.021051921
0.06 1.090279625
0.07 1.150180998
0.08 1.197584966
0.09 1.230460616
0.1 1.247526366
0.11 1.247813721
0.12 1.230908982
0.13 1.197544859
------------------------------
(the two numbers in a row are separated by a space)

when I export it in Matlab, It rounds off the numbers in the second column to 4 digits after decimal.


I want Matlab to import it as it is, i.e., with the same number of digits as in the text file.


How to do that ?? Can somebody give me the right code for the same???
 

You are probably misinterpreting the values printed v.s. stored in memory.

The following link has some information on matlab's number formats.
https://www.mathworks.com/help/matlab/matlab_prog/floating-point-numbers.html

I suspect you are seeing the display showing you the value read from the file but it's only displaying the first 5 significant digits even though it's storing a double precision value. You can see in some of the examples when they enter higher precision values and the display shows a 5 significant digit value.

As it appears matlab uses IEE754 it should have 15-17 significant digits of precision.

And this link shows how to modify the default format of numbers displayed in matlab.
 

Enter the following command into Matlab:


Code Matlab M - [expand]
1
format long g



Then print out your values. You'll see they're stored to double precision.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…