Textscan with '@' as delimiter
이전 댓글 표시
I'm working with an inherited script that calls TEXTSCAN as follows:
allData = textscan(fid,'%s','Delimiter','@');
What does the at-sign delimiter parameter do, and is this documented anywhere?
I don't see anything in the TEXTSCAN help for this, but when I parse the same text file with and without that parameter specified, I get different results. The input file contains no explicit at-sign characters anywhere. Is TEXTSCAN treating the @ as some special control character?
댓글 수: 5
Mohammad Sami
2020년 5월 8일
I think most likely explanation is, when you do not specify a Delimiter, Matlab will use the default delimiter. I believe the default delimiters are white space, i.e. spaces, tabs or newline characters.
If you specify a delimiter, Matlab will use the specified delimiter and you will get different results.
Walter Roberson
2020년 5월 8일
With the delimiter set to something that does not occur in the text, the effect would be to scan until end of file.
Walter Roberson
2020년 5월 9일
Please attach your data file, and also the code you use to reproduce the problem.
The tests I have done find nothing special about using @ . The effect I get when I use any character not found in the file exactly the same as if I use
textscan(fid, '%s', 'Delimiter', '\n', 'Multiple', true)
or
textscan(fid, '%s', 'whitespace', '\n')
and the effect is:
- each time the %s fires, skip all leading spaces and newlines
- once the %s starts reading something non-blank, continue until the first newline
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Type Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!