How do I access a certain directory?

13 vues (au cours des 30 derniers jours)
James
James le 9 Sep 2019
Commenté : madhan ravi le 9 Sep 2019
How do I access a certain directory, so i can then retrieve certain images from that specified directory?

Réponses (2)

Jan
Jan le 9 Sep 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 le 9 Sep 2019
  3 commentaires
Jan
Jan le 9 Sep 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 le 9 Sep 2019
Ah :) thanks for the tips.

Connectez-vous pour commenter.

Catégories

En savoir plus sur File Operations dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by