How to read a text file on a specific line having string and numeric data

1 回表示 (過去 30 日間)
Yrobel Lima
Yrobel Lima 2019 年 4 月 25 日
コメント済み: Yrobel Lima 2019 年 4 月 25 日
Hi,
How can I read and convert data from a text file on specific lines to a matrix.
The file I have has several formats, for example:
................................................................
. . . . .
. POINT . COORDINATE . RATE VALUES . MEDIUM .
. . . . .
................................................................
. . . . FA .
. 1 . 0.00 . 0.27504825E+13 . .
. 2 . 11.32 . 0.31004130E+13 . .
----------------------------------------------------------------
. . . . FA .
+ . 3 . 11.32 . 0.31004130E+13 . .
. 4 . 22.65 . 0.34565566E+13 . .
----------------------------------------------------------------
etc...

回答 (1 件)

Image Analyst
Image Analyst 2019 年 4 月 25 日
You forgot to attach the file with the paper clip icon. Please do so.
You could read in a line at a time with fgetl() and, if the line does not contain an FA or -----, use strsplit() with that dot character as the delimiter to split up the line into 3 numbers.
  1 件のコメント
Yrobel Lima
Yrobel Lima 2019 年 4 月 25 日
Thanks for your reply. I attached the file.
Regards.

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

カテゴリ

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