フィルターのクリア

My .txt file imports as a character string

1 回表示 (過去 30 日間)
Chad Greene
Chad Greene 2012 年 6 月 26 日
Hi all,
I'd like to import a text file as a matrix of data. Here's what I have so far:
thefilename = gunzip('ftp://podaac-ftp.jpl.nasa.gov/allData/grace/L2/CSR/RL05/GAC-2_2004001-2004013_0013_UTCSR_0000_0005.gz');
copyfile(char(thefilename),[char(thefilename),'.txt']);
If I double-click on the resultant .txt file, I see that the formatted data begins on line 9, after 8 rows of headers. How can I tell Matlab to import the columns of data from rows 9:end?
Thanks, Chad

採用された回答

Walter Roberson
Walter Roberson 2012 年 6 月 26 日
textscan() with the HeaderLines option.
  1 件のコメント
Chad Greene
Chad Greene 2012 年 6 月 26 日
Brilliant! Until now I had a hard time finding the data after using textscan. When I'd use C=textscan(yada_yada), I'd then end up with a character set C, from which I did not now how to extract the data. Now I see I needed to use C{2} for the column two, etc. Here's the solution:
fid = fopen([char(thefilename),'.txt']);
C = textscan(fid,'%s %f %f %f %f %f %f %f %f %s','headerlines',8);
fclose(fid);
Then each column n can be accessed by C{n}. Thanks Walter!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by