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

7 Ansichten (letzte 30 Tage)
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).

Akzeptierte Antwort

Guillaume
Guillaume am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import and Export finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by