フィルターのクリア

Using FSCANF to read and extra data into matrix

1 回表示 (過去 30 日間)
ERC
ERC 2013 年 7 月 24 日
My data has 6 columns and 10 rows of data. Columns 1, 3, and 5 consist of numbers expressed in decimal. Columns 2, 4, & 4 consist of non-numeric texts.
It looks like this:
Col1 Col2 Col3 Col4 Col5 Col6
01 text 123 text 123 text
02 test 456 text 456 text
etc.
How do I use use a single FSCANF to read the three numerical columns into a 10x3 matrix, extract and display the individual columns?
Thanks in advance.

採用された回答

dpb
dpb 2013 年 7 月 24 日
fmt=[repmat('%d %*s',1,3) '\n'];
A = fscanf(fid,fmt,[3,inf])';
  1 件のコメント
ERC
ERC 2013 年 7 月 24 日
Thank you!

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

その他の回答 (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