how to get file name when i take a image file from imgetfile
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
i want only file name of my image file which i take from imgetfile. as i want to save the file name and data i collected/processed on that particular image file.
Respuestas (1)
MHN
el 17 de Feb. de 2016
Editada: MHN
el 17 de Feb. de 2016
One easy way is to write a code for that ! (assumption: there is no dot (.) in the name of the image)
IMPORTANT NOTE : if you are using Windows, you have to change '/' to '\'.
[filename, user_canceled] = imgetfile;
if user_canceled==0
L = filename=='/';
m = find(L==1,1,'last');
L = filename=='.';
n = find(L==1,1,'last');
str = filename(m+1:n-1)
end
2 comentarios
MHN
el 17 de Feb. de 2016
Editada: MHN
el 17 de Feb. de 2016
You can use the following code to make sure it works for Windows or other OSs :
[filename, user_canceled] = imgetfile;
if user_canceled==0
if ispc
L = filename=='\';
else
L = filename=='/';
end
m = find(L==1,1,'last');
L = filename=='.';
n = find(L==1,1,'last');
str = filename(m+1:n-1)
end
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!