How to handle load errors.
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Vahe Ghazikhanian
le 27 Fév 2019
Commenté : Vahe Ghazikhanian
le 28 Fév 2019
I have a large number of files to read and proces. A small percentage of these files are corrupted. I use the load() command to load individual files in a parfor loop statement. Unfortunately my program stops ececution when one of these corrupt files gives an error when loading.
How could I continue execution? Buy this I mean advancing the loop variable and not processing the data from faulty file?
I also need to record the name of the file that triggered the error.
0 commentaires
Réponse acceptée
Walter Roberson
le 27 Fév 2019
try
filestruct = load(FileName);
catch ME
bad_files{end+1} = FileName;
continue; %skip computing with this file
end
3 commentaires
Walter Roberson
le 27 Fév 2019
I need to see the surrounding code.
In my sample code, FileName should be replaced by the name of the variable that the file name is stored in.
bad_files should be initialized as {}
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Whos dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!