Significant figures are being trimmed when I read from a .txt file
2 views (last 30 days)
Show older comments
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 Comment
Answers (2)
Stephen23
on 2 Sep 2016
Edited: Stephen23
on 2 Sep 2016
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
0 Comments
Star Strider
on 2 Sep 2016
You’re limited to 16 significant figures in MATLAB double-precision variables:
format long
Q1 = 3.55560341707837150E+9
Q1 =
3.555603417078372e+09
0 Comments
See Also
Categories
Find more on Workspace Variables and MAT Files 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!