skip a load error
이전 댓글 표시
Hi,
I want to load some mat files in my folder according to a certain criteria. Sometimes this file doesn't exist. How can I continue to load the next file with causing the program to stop because of the error? example:
UID=unique(ID);
for i=1:size(UID,1) filename=['Data' num2str(UID(i,1))]; load (filename,'DataFinal')
%%% here I want to manipulate the data end
if load returns an error that such a file doesn't exist , how can I continue the loop without any interruption. Regards
채택된 답변
추가 답변 (1개)
Matt Tearle
2011년 3월 12일
0 개 추천
You can use exist to check if the file exists, but perhaps another approach would be to use cellstr(ls('Data*')) to get a list of the files first, then loop over those.
카테고리
도움말 센터 및 File Exchange에서 Variables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!