フィルターのクリア

Problem with dlmread reading data

2 ビュー (過去 30 日間)
Jonathan Gundorph Jansen
Jonathan Gundorph Jansen 2018 年 3 月 1 日
回答済み: Star Strider 2018 年 3 月 1 日
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++.

採用された回答

Star Strider
Star Strider 2018 年 3 月 1 日
Your file is not appropriate for dlmread. Use textscan (link) instead.
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 件)

カテゴリ

Help Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by