How to handle load errors.
13 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-2-27
try
filestruct = load(FileName);
catch ME
bad_files{end+1} = FileName;
continue; %skip computing with this file
end
3 个评论
Walter Roberson
2019-2-27
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 {}
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!