Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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');

Risposte (1)

Star Strider
Star Strider il 7 Giu 2015
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.

Categorie

Scopri di più su Large Files and Big Data in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by