Reading header section only from file

조회 수: 4 (최근 30일)
Dhani Dharmaprani
Dhani Dharmaprani 2017년 1월 17일
댓글: Walter Roberson 2020년 2월 6일
Hi,
I have a .txt file consisting of a header section and data section (attached). I am interested in only reading the header portion of the file, but what is the best way to do this? I would like the final output to be stored as a char as shown in the picture below, and have tried fscanf to do so but can't quite figure it out.
I am quite a novice with Matlab so any help is greatly appreciated!

채택된 답변

Image Analyst
Image Analyst 2017년 1월 17일
Try this:
str = fileread('test.txt')
index = strfind(str, '[Data]');
header = str(1:(index-1));
  댓글 수: 5
leydy Garcia
leydy Garcia 2020년 2월 6일
what is [Data] in this example?
Walter Roberson
Walter Roberson 2020년 2월 6일
[Data] is line 295 of the user's file test.txt . It is the header that marks the end of the section the user wants to extract; the user wants the header section of the data rather than the numeric data.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by