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

 Respuesta aceptada

Ken Atwell
Ken Atwell el 10 de Mzo. de 2012

0 votos

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 comentario

Jerry
Jerry el 10 de Mzo. de 2012
Thanks a lot.
Forgot the matlab has try.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Startup and Shutdown en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 10 de Mzo. de 2012

Community Treasure Hunt

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

Start Hunting!

Translated by