How to read a text file on a specific line having string and numeric data
조회 수: 1 (최근 30일)
이전 댓글 표시
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...
댓글 수: 0
답변 (1개)
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.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!