필터 지우기
필터 지우기

How to continue execution of textscan if it cannot match formatSpec to the data

조회 수: 1 (최근 30일)
Yaameen
Yaameen 2015년 6월 7일
답변: Star Strider 2015년 6월 7일
34,35,36,
34,35,36,37,
34,35,36,
Let say I have the above 3 lines of data which I am reading using textscan. Let say textscan's formatSpec is '%d %d %d'. Then in this case it stops after 1st data line. So I would like to implement a script which continues with another formatSpec if textscan couldn't match initial formatSpec. How can I do it? The logic is below.
fmt_one = '%d %d %d';
fmt_one = '%d %d %d %d';
C = textscan(fileID,'%d %d %d');
if textscan stopped
C = textscan(fileID,'%d %d %d %d');

답변 (1개)

Star Strider
Star Strider 2015년 6월 7일
I would use:
C = textscan(fileID,'%d %d %d %d');
adding the appropriate 'Delimiter', 'CollectOutput', 'EndOfLine' and other name-value pairs as required. If textscan encounters a blank space, it should substitute NaN for the missing value.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by