フィルターのクリア

Using FGETL to skip 2 header lines

10 ビュー (過去 30 日間)
ERC
ERC 2013 年 7 月 24 日
How do I use FGETL to skip 2 header lines?
My data file looks like this
Row 1: ID FName LName Year Class
Row 2: ---------------------------------
Row 3: data starts here
After I open the file with FOPEN
fid=fopen('textfile.dat','r');
How do I use FGETL to skip the 2 header lines (rows 1 & 2)?
Thanks in advance.

採用された回答

per isakson
per isakson 2013 年 7 月 24 日
Call it twice and ignore the results.
  5 件のコメント
Cedric
Cedric 2013 年 7 月 24 日
Don't forget to [ Accept the Answer ] if it solved your problem.
ERC
ERC 2013 年 7 月 24 日
Done. Thanks for the reminder.

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

その他の回答 (1 件)

Dan Seal
Dan Seal 2013 年 7 月 27 日
A good way to read data from text files with headers is with the textscan function. When calling textscan, you an specify a number of header rows in your file. For example, if ID and Year are numeric and the other columns are strings, use:
fid=fopen('textfile.dat','r');
C = textscan(fid, '%d %s %s %d %s', 'HeaderLines', 2);

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by