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

1 view (last 30 days)
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...

Answers (1)

Image Analyst
Image Analyst on 25 Apr 2019
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.

Categories

Find more on Data Import and Export in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!