Effacer les filtres
Effacer les filtres

How to judge "load" function

4 vues (au cours des 30 derniers jours)
Jerry
Jerry le 10 Mar 2012
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

Réponse acceptée

Ken Atwell
Ken Atwell le 10 Mar 2012
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 commentaire
Jerry
Jerry le 10 Mar 2012
Thanks a lot.
Forgot the matlab has try.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by