Hello,
I would like to extract all the numeric data out of a mixed file where the total line length needs to be determined. I have put a screenshot of the first 5 lines of the file.
In the file, I wish to extract the 13 numeric values and ignore the '#' at the end. I have tried to do this below:
fid = fopen('Boundary.cli');
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d',1);
fclose(fid);
This produces the following 1x13 cell:
The issue is that i would like to the read the whole of the file and then convert the cell to a double array of n x 13. Where n is the number of lines of the file.
I would greatly appreciate any help from anyone who knows how to solve this issue.

 채택된 답변

Jan
Jan 2017년 11월 28일
편집: Jan 2017년 11월 28일

0 개 추천

What about:
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d %s');
Then remove the last column in FC. Or:
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d %[^\n]');

댓글 수: 2

Stephen23
Stephen23 2017년 11월 28일
@apex116: read the textscan documentation and use the CollectOutput option.
Dear Stephen, Thank your help. However I am having difficulties with the second suggestion:
FC = textscan(fid, '%d %d %d %d %d %d %d %d %d %d %d %d %d %[^\n]');
The problem is that it doesn't allow me to read more than the first line.
The only reason I am asking as i might have a varying number of string characters following the numeric data.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

질문:

2017년 11월 28일

댓글:

2017년 11월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by