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

7 次查看(过去 30 天)
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).

采纳的回答

Guillaume
Guillaume 2018-11-1
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Import and Export 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by