필터 지우기
필터 지우기

How to handle load errors.

조회 수: 13 (최근 30일)
Vahe Ghazikhanian
Vahe Ghazikhanian 2019년 2월 27일
댓글: Vahe Ghazikhanian 2019년 2월 28일
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.

채택된 답변

Walter Roberson
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
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 {}
Vahe Ghazikhanian
Vahe Ghazikhanian 2019년 2월 28일
Thanks, after I initialized it seems to work.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by