Problem with dlmread reading data
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Jonathan Gundorph Jansen
am 1 Mär. 2018
Beantwortet: Star Strider
am 1 Mär. 2018
Dear Mathworks community,
I am having a problem using the dlmread function. I want to read data from a GNU zipped file (gravitational data from the GRACE satellite) into MATLAB so I can work with it. This is my approach so far:
MyFolderInfo = dir('C:\Users\my\Desktop\Skole\6. Semester\Bachelor_Projekt\GRACE')
listing = MyFolderInfo(4).name
M = dlmread(listing,' ', [8, 0, 5150, 9])
So I am succesfully loading the data from dir, but when I want to use the dlmread function I get the following error:
*Error using dlmread (line 147)
Mismatch between file and format character vector.
Trouble reading 'Numeric' field from file (row number 1, field number 1) ==> GRCOF2 0 0 0.883194575888E-11
0.000000000000E+00 0.0000E+00 0.0000E+00 20020405.0000 20020501.0000 nnnn \n*
I want to use only the numerical data and exclude the columns "GRCOF2" and "nnnn", but when I try to make the row and column offset, like below, i just get the following error.
M = dlmread(listing,' ', [8, 1, 5150, 8])
Trouble reading 'Numeric' field from file (row number 1, field number 16) ==> nnnn \n
Its almost as it doesn't register my max. column offset correctly. Can anyone help me?
Best Regards Jonathan
PS. I've attached an image of data file that I want to work with in this question, if that helps. It's opened in notepad++.
0 Kommentare
Akzeptierte Antwort
Star Strider
am 1 Mär. 2018
This should get you started:
fidi = fopen(MyFolderInfo(4).name, 'rt');
Data = textscan(fidi, '%s%f%f%f%f%f%f%f%f%s', 'HeaderLines',8, 'CollectOutput',1);
You may have to experiment with the name-value pairs in textscan to work with your file. See the documentation for all the possibilities.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Import and Export finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!