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

 Akzeptierte Antwort

Ken Atwell
Ken Atwell am 10 Mär. 2012

0 Stimmen

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 Kommentar

Jerry
Jerry am 10 Mär. 2012
Thanks a lot.
Forgot the matlab has try.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by