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

7 ビュー (過去 30 日間)
Math Enthusiast
Math Enthusiast 2018 年 11 月 1 日
回答済み: Guillaume 2018 年 11 月 1 日
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 Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by