How do I access a certain directory?

46 次查看(过去 30 天)
How do I access a certain directory, so i can then retrieve certain images from that specified directory?

回答(2 个)

Jan
Jan 2019-9-9
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 2019-9-9
  3 个评论
Jan
Jan 2019-9-9
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by