Read mixed text file into array

I need to read this text file into array, splitting at multiple delimiters, for example at '=','space',etc. I tried 'fscanf', which works for single row, but since the rows have different structure it won't work for the whole file. Can you please help me with this?

댓글 수: 4

Jan
Jan 2017년 11월 23일
What is fixed and what is variable in the structure? Can e.g. the "(DEG)" change from block to block or could we ignore this detail gratefully? Is the contents of the "# column" line trivial or can it be reordered such that parsing it is obligatory?
Rafik
Rafik 2017년 11월 23일
"(DEG)" is fixed, as well as most of the strings. The VALUES of the average gas temperature, pressure etc. are changing. The contents of the '# column' line are trivial. However, the last three lines of each block are variables, and should be parsed. I've attached the txt file, in case you need it. Thank you.
Jan
Jan 2017년 11월 25일
@Rafik: And what is the wanted output? The actual commands are not complicated. fopen, fgetl and fscanf with a specific format are enough. But there are still too many open details to provide reliable code, e.g. if the number of columns in the data is fixed. A guess, what you want as output, might be more confusing than useful, if it differ from your needs. Therefore I hesitate to post code as an answer.
Rafik
Rafik 2017년 11월 26일
I need to take the contents of the 'number' column and the 'X' column of each block, and put them into columns of the output matrix (one output matrix for each block). First matrix for crank=-179.9904, second matrix for crank=10. Example output:

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

제품

질문:

2017년 11월 23일

댓글:

2017년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by