How do I access a certain directory?

How do I access a certain directory, so i can then retrieve certain images from that specified directory?

Respuestas (2)

Jan
Jan el 9 de Sept. de 2019
You can define the path of a file to access it:
Folder = 'C:\Temp\';
FileList = dir(fullfile(Folder, '*.jpg'));
for iFile = 1:numel(FileList)
File = fullfile(FileList(iFile).folder, FileList(iFile).name);
% Do what you want with this file, e.g.:
Img = imread(File)
end
madhan ravi
madhan ravi el 9 de Sept. de 2019
help cd

3 comentarios

Stephen23
Stephen23 el 9 de Sept. de 2019
Editada: Stephen23 el 9 de Sept. de 2019
Jan
Jan el 9 de Sept. de 2019
It is unsafe to change to a specific directory only to access the included files. Using absolute path names is better, because this is not confused by GUI or TIMER callbacks, which call cd again unexpectedly.
madhan ravi
madhan ravi el 9 de Sept. de 2019
Ah :) thanks for the tips.

Iniciar sesión para comentar.

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Productos

Versión

R2019a

Etiquetas

Preguntada:

el 9 de Sept. de 2019

Comentada:

el 9 de Sept. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by