필터 지우기
필터 지우기

Large format spec statement in textscan

조회 수: 4 (최근 30일)
Aaron Smith
Aaron Smith 2017년 2월 15일
댓글: Stephen23 2017년 2월 15일
I have a very large matrix file that I am trying to textscan and reform into blocks of equal size. The matrix is 51200 rows of 1025 integers each separated by semicolons and I am attempting to create 50 blocks of 1024 x 1025. My question was, because my rows of data contain 1025 integers, I can not write '%d %d %d %d %d....' 1025 times. Is there a way to state that there are 1025 integers (for example '1025*%d'). Also, Is there a way to command my desired reformatting of the data into blocks in the textscan line?
  댓글 수: 2
Stephen23
Stephen23 2017년 2월 15일
편집: Stephen23 2017년 2월 15일
@Aaron Smith: when you ask questions that are very closely related to other questions, it helps us a lot if you put a link to the other questions. This means we can check what information you have already been given, and avoids pointless and annoying repetition of the same questions and topics.

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

답변 (1개)

dpb
dpb 2017년 2월 15일
fmt=repmat('%d',1,1025);
data=textscan(fid,fmt,...
For the second, use the option N multiplier to control the number of times the format statement is applied and enclose the textscan call in a loop. Each block can be a cell array element as one choice or can process and discard if the algorithm lends itself to that.
There's one handy 'trick' with textscan which is to use an empty string for the format string and it will automagically determine the record size and return the array in the shape of the file storage. Then you can reshape or mat2cell as desired.
  댓글 수: 2
Aaron Smith
Aaron Smith 2017년 2월 15일
What type of loop would work for this purpose? While ~feof()? I'm not sure how to format the loop with the N multiplier. Also using while~feof has caused problems in the past for me with an error (invalid file identifier) arising. Any clarification you can provide would be greatly appreciated as you initial answer is.
Stephen23
Stephen23 2017년 2월 15일
편집: Stephen23 2017년 2월 15일

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

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by