필터 지우기
필터 지우기

Format specifiers for TEXTSCAN

조회 수: 4 (최근 30일)
AMM
AMM 2020년 5월 3일
댓글: AMM 2020년 5월 3일
I'm confused by the TEXTSCAN documentation regarding the format specifier. In the following call (from code I did not write, but need to understand),
data = textscan(textLine,'%f%f%f%f%*[^\n]');
I get that it will attempt to parse four floats, but what about the rest of the specifier?
If I'm reading the docs correctly, the '%*' means "skip the next field," but no width is given. So does this just skip characters until it encounters the first one excluded by the '[^\n]'? In other words, does this construction just mean "parse four floats, then ignore until end of line"?
Thanks in advance for any clarifications,
-AMM

채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 3일
Yes, that is exactly what that construct means, 4 floats and then ignore to newline.
The newline itself would not be consumed by the format, but nearly all of the % specifiers skip leading whitespace so in practice that seldom makes a difference.
  댓글 수: 1
AMM
AMM 2020년 5월 3일
Thank you Walter!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by