"Exist" return 0 for a file it displays when using "ls"
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm using Matlab 2015a on window
I use "exist" to check the existence of a .stl file before opening it. This step was without any problem so far until last week. When checking the existence of files I had checked already in the past it return 0.
To make sure I used "ls", and runned "exist" on a copy paste of a file returned by "ls". But Matlab still denies the existence of the file
See below:
>> ls('M:\BM\Sebastian Ehrig\SJ\MeshSpheroids')
.
..
Movies
ellipsoid_x8_y8_z1_refSph6_sigma_0.417_Area452.389.stl
ellipsoid_x8_y8_z1_refSph6_sigma_0.417_Area452.389_Velocity_0.1.mat
old
meshes
structures >> exist('M:\BM\Sebastian Ehrig\SJ\MeshSpheroids\ellipsoid_x8_y8_z1_refSph6_sigma_0.417_Area452.389.stl')
ans =
0
>> exist('M:\BM\Sebastian Ehrig\SJ\MeshSpheroids\ellipsoid_x8_y8_z1_refSph6_sigma_0.417_Area452.389_Velocity_0.1.mat')
ans =
0
>> exist('M:\BM\Sebastian Ehrig\SJ\MeshSpheroids')
ans =
7
0 comentarios
Respuestas (3)
John D'Errico
el 22 de Jun. de 2016
The "." characters in the middle of your .mat file name probably cause exist to fail. This is generally a bad idea. A "." character is used to indicate an extension. So, the MATLAB exist tool looks for a file with the wrong name. It did not find a file with that name, even though ls sees a file in that directory.
The solution is more careful naming of your files.
0 comentarios
Thorsten
el 22 de Jun. de 2016
On my system (MacOS 10.11) Matlab returns 2, as expected. I would try to get rid of the '.' in the file names and see if it works then. Of course if you do not have a pre-Windows-95 it should work with as many dots as you like, but still...
0 comentarios
Walter Roberson
el 22 de Jun. de 2016
You might have non-printing graphics characters in the name.
dinfo = dir('M:\BM\Sebastian Ehrig\SJ\MeshSpheroids\*.stl');
fprintf('name looks like: "%s"\n', dinfo.name);
fprintf('which is length %d, and has representation\n', length(dinfo.name))
double(dinfo.name)
0 comentarios
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects 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!