Write arrays with exact values from .txt files with scientific notation

9 views (last 30 days)
Hello together,
i read values from .txt files. The values are in scientific notation and have the form
My suggestion for this:
folder = ['foldername'];
filename_t = fullfile(folder, sprintf('%dHz_t_LS_%d.txt', f_sim, LS));
fileID_t = fopen(filename_t, 'rt');
t_total = textscan(fileID_t, '%sf,'HeaderLines',0);
t_total = t_total{1};
But unfortunately it never gives the correct value. I only get values in the form 0.0750, which is much too low accuracy.
i have already experimented with %16.8f etc., but did not reach my goal
Many greetings
teasy on 13 Sep 2020
this was a copy error, so the correct command would be
t_total = textscan(fileID_t, '%f','HeaderLines',0);
but even this does not give the desired result

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Sep 2020
I suspect you have the format set at:
format short
Setting it to
format long
may be the solution,.
teasy on 13 Sep 2020
The problem was that I looked at the variable in the workspace and the workspace display was short.
Sorry for the circumstances but thanks for the help!

Sign in to comment.

More Answers (0)


Find more on Printing and Saving 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!