dlmread does not read numeric data correctly from ascii file having whitespaces as delimiter
Show older comments
Wondering what is wrong with dlmread? I have always used dlmread so reliably but this data is giving troubles (data file attached).
The following is the content of the file I am trying to read using dlmread.
0.14700000E+00 -0.13086337E+00 0.15900000E-02 0.12586876E-96 0.18594589E-96 0.10390510E-97
0.14286337E+00 -0.14000000E+00 0.15900000E-02 -0.26617510E-98 -0.11121459E-98 0.47342035E-99
0.14286337E+00 -0.13913663E+00 0.15900000E-02 -0.41570828-100 -0.31874541E-99 -0.14472703-100
0.14286337E+00 -0.13750000E+00 0.15900000E-02 0.18919319E-99 0.82353677E-99 -0.25976626-100
0.14286337E+00 -0.13586337E+00 0.15900000E-02 -0.26139605E-98 0.19842495E-99 -0.41547105E-99
0.14450000E+00 -0.14000000E+00 0.15900000E-02 0.14322438E-98 0.15506484E-98 0.80355250-100
0.14450000E+00 -0.13913663E+00 0.15900000E-02 -0.25906476E-99 -0.36585160E-99 -0.50350642-100
0.14450000E+00 -0.13750000E+00 0.15900000E-02 0.33632587E-99 0.42188285E-99 0.87000561-100
0.14450000E+00 -0.13586337E+00 0.15900000E-02 -0.19484780E-99 -0.24493903E-98 -0.33289401-100
0.14613663E+00 -0.14000000E+00 0.15900000E-02 -0.14523082E-98 -0.14915798E-98 -0.14910675E-99
So whenever I try to read using the dlmread command, the output of read data matrix is as follows:
>> field=dlmread('dlmread_incorrectlyReadsThisFileData.txt');
>> field
field =
147.000000000000e-003 -130.863370000000e-003 1.59000000000000e-003 125.868760000000e-099 185.945890000000e-099 10.3905100000000e-099
142.863370000000e-003 -140.000000000000e-003 1.59000000000000e-003 -2.66175100000000e-099 -1.11214590000000e-099 473.420350000000e-102
142.863370000000e-003 -139.136630000000e-003 1.59000000000000e-003 -415.708280000000e-003 -100.000000000000e+000 -318.745410000000e-102
-144.727030000000e-003 -100.000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000
142.863370000000e-003 -137.500000000000e-003 1.59000000000000e-003 189.193190000000e-102 823.536770000000e-102 -259.766260000000e-003
-100.000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000
142.863370000000e-003 -135.863370000000e-003 1.59000000000000e-003 -2.61396050000000e-099 198.424950000000e-102 -415.471050000000e-102
144.500000000000e-003 -140.000000000000e-003 1.59000000000000e-003 1.43224380000000e-099 1.55064840000000e-099 803.552500000000e-003
-100.000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000 0.00000000000000e+000
144.500000000000e-003 -139.136630000000e-003 1.59000000000000e-003 -259.064760000000e-102 -365.851600000000e-102 -503.506420000000e-003
Any ideas why it reads only the first two rows correctly but starts storing incorrect data from the third line in the 'field' matrix?
1 Comment
Walter Roberson
on 19 Dec 2018
Please do not close questions that have an answer.
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB 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!