Reading/writing text file while excluding header
이전 댓글 표시
I'm new-ish to MATLAB, and until now I've only used it to perform Matrix Displacement Method analyses for structures classes.
I have large earthquake record files that I would like to read in. They have headers (4 lines) that I would like to omit, and 5 columns of acceleration data (the number of rows depends on the size of the earthquake record). Is there a way to read in this data and then write the array to a new text file? I've spent hours pouring over past forum topics, and I haven't had any luck with my attempts.
The closest I've come is to use importdata(), but the 'data' array returns dimensions that don't seem right (that, and I don't know how to access the elements of a structured array like 'data').
Hints would be much, much appreciated!
댓글 수: 5
Matt Kindig
2013년 4월 3일
I would use textscan() with the 'HeaderLines' option.
doc textscan
James
2013년 4월 3일
Matt Kindig
2013년 4월 4일
Can you post the code that you tried?
Also, approximately how many rows do you have?
James
2013년 4월 4일
편집: Walter Roberson
2013년 4월 4일
Walter Roberson
2013년 4월 4일
In the above there appears to be empty lines in the headers. If those empty lines are present in the file, then you need to include those in the count of header lines.
You should not be using fprintf() for an input file.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Data Preparation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!