Significant figures are being trimmed when I read from a .txt file

2 ビュー (過去 30 日間)
Karoly Fodor
Karoly Fodor 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
Hello, and thank you in advance for your time.
I am trying to read data from text files. The first column contains absolute time, so the data points look something like this: 3.55560341707837150E+9. However, the data is being truncated to show only this: 3.5556e+09.
It is very important that I use all of the digits, as I need to look at very small increments of time between certain points.
Here is the code I use to access the files:
[fileName1,filePath1] = uigetfile('*', 'Select force data file', '.');
force = load( fullfile(filePath1,fileName1) );
[fileName2,filePath2] = uigetfile('*', 'Select lvdt data file', '.');
volt = load( fullfile(filePath2,fileName2) );
In what way could I alter this code to ensure that all significant figures are read?
  1 件のコメント
Stephen23
Stephen23 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
"the data is being truncated to show only this"
Yes, it only shows that. But the data is stored in MATLAB's memory as a full double floating point value, which means 15-17 significant digits.

サインインしてコメントする。

回答 (2 件)

Stephen23
Stephen23 2016 年 9 月 2 日
編集済み: Stephen23 2016 年 9 月 2 日
Your data is there, this is just a question of how it is displayed. Read the format documentation for other display precisions:
>> 3.55560341707837150E+9
ans =
3.5556e+09
>> format longg
>> 3.55560341707837150E+9
ans =
3555603417.07837
>> format longe
>> 3.55560341707837150E+9
ans =
3.555603417078372e+09

Star Strider
Star Strider 2016 年 9 月 2 日
You’re limited to 16 significant figures in MATLAB double-precision variables:
format long
Q1 = 3.55560341707837150E+9
Q1 =
3.555603417078372e+09

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by