How to judge "load" function

Hi guys:
Is there a way to judge whether a '.txt' file could be loaded by "load" function?
Some of my files are matrix which could be loaded by "load" but some are not.
Is there a way to separate them?
Thanks a lot

 채택된 답변

Ken Atwell
Ken Atwell 2012년 3월 10일

0 개 추천

You could perform the load in a try/catch block and react accordingly:
try
load(filename);
catch e
% Something went wrong -- not a valid file to load?
end

댓글 수: 1

Jerry
Jerry 2012년 3월 10일
Thanks a lot.
Forgot the matlab has try.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2012년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by