Check for existence of mat-file in search path
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Just came over an "interesting" problem. If I run exist('mandrill','file'), I get false back, which I normally would interpret as the (mat)file doesn't exist in the Matlab search path. However, imgdata=load('mandrill') works perfectly fine. Same applies for the 'seamount' image (or any other images that come along with Matlab/toolboxes).
How come Matlab knows where to look for the file/data when using load() and not when using exist()? Problem is that I'd like to have a test similar to
if ~exist('mandrill')
bla bla bla;
return;
else
bla bla bla;
return;
end
But at the moment this won't work. Any suggestions for how to solve this?
If it should matter I use Matlab R2012a.
Best regards, dm
1 comentario
Henrik
el 6 de Jul. de 2016
Could be because "exist" is looking for a .m file when you don't specify the fileformat. If you instead write ~exist('mandrill.mat','file') it should work.
Respuesta aceptada
Más respuestas (0)
Ver también
Categorías
Más información sobre File Operations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!