Matlab Text File header information reading and ploting

조회 수: 1 (최근 30일)
Matlab User
Matlab User 2016년 8월 2일
댓글: Rena Berman 2016년 10월 30일
Hi, I am trying to plot multiple text files with many block sizes in matlab, i was able to plot each text file. My problem. My problem is with header information reading. The header information has same string comments such as, date, year, measurement types, but header length can vary between 20-25. My question is that how can i handle varying text file header information? Im trying to use some character signs or string from the text header to make skip and jump into numerical matrix. By the way my numerical matrix has 24 (rows) by 5 (Columns). Number of rows are not always 24,but can also vary between 1-24 depending on text data collection ( I was able to handle matrix indexes, just for your information). Thanks!!!
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 8월 3일
I am not sure if those numbers on the left are for illustration or are part of the file?
I am not sure if multiple structures like that can occur in one file, as your examples show two like that seemingly together?
Rena Berman
Rena Berman 2016년 10월 30일
(Answers dev) restored question

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

답변 (1개)

Pham Dang
Pham Dang 2016년 8월 10일
편집: Pham Dang 2016년 8월 10일
You may consider a small processing to format your file. If you are on Linux, you can use the following command in the matlab console :
!grep -e "data\|^[ ]\+[0-9]" Example-1.txt
This will display only the lines with the word "data" or "begining with several spaces followed by a number". In order to save this result to a file you should use a command like this :
!grep -e "data\|^[ ]\+[0-9]" Example-1.txt > data-noheaders.txt
It will write the output lines to the file "data-noheaders.txt". You may consider using the eval command in order to process all your files.
Then you can parse the resulting file line by line ; if it begins by "data", create a new data matrix and fill it with the following data until a new "data" string is read.
Hope this helps

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by