필터 지우기
필터 지우기

complex repeating input format

조회 수: 10 (최근 30일)
Stu Schwartz
Stu Schwartz 2020년 7월 28일
댓글: Stephen23 2020년 7월 29일
Hi: Looking for help on reading in a large file with 490 columns per record. First 5 columns have a distinct repeating format (%s %f %f %f %f %s) followed by 485 columns that repeat the same 5 column formant (%f %s %s %s %s) 97 times. I'd like to use a FORTRAN like construct in a format spect to indicate the second format spec is repeated 97 times after the first. Can't figure out how to do this without a format spec with 490 distinct entries (485 of which are just repeating the 5-column format). Any suggestions would be much appreciated.

채택된 답변

Stephen23
Stephen23 2020년 7월 29일
fmt = repmat('%f%s%s%s%s',1,97);
fmt = ['%s%f%f%f%f%s',fmt];
Note that you wrote "First 5 columns..." but your example format string contains 6 format specifiers.
  댓글 수: 2
Stu Schwartz
Stu Schwartz 2020년 7월 29일
Ahhh! Many thanks.
Yes - 'first 5" discrepancy was just a typo.
Thanks again for your help.
Stephen23
Stephen23 2020년 7월 29일
@Stu Schwartz: my pleasure. Please remember to accept my answer!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by