Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Yaameen
Yaameen le 7 Juin 2015
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');

Réponses (1)

Star Strider
Star Strider le 7 Juin 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.

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by