Avoid rounding off the decimal values,while loading the data from textfile

7 views (last 30 days)
Hi,
I am trying to load a certain text file,which contains 2 columns of data. I have written this:
R = load('data.txt');
Upon loading the data, I observed that, data in the columns has been rounded off to first 4 digits only. How can we get the complete data (for example, if the data has decimals upto 6 digits).

Accepted Answer

Guillaume
Guillaume on 1 Nov 2018
I observed that, data in the columns has been rounded off to first 4 digits only
How did you observed that?
Note that the way matlab displays a number (which can be easily adjusted with format) and the way matlab stores the values in memory are two very different things:
>>format shortg
>>a = 1.23456789
a =
1.2346
a appears to only store 4 decimals, however
>>a-1.2346
ans =
6.789e-5
clearly it still had all the decimals
>>format longg
>>a
a =
1.23456789
Yep, still there.

More Answers (0)

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!