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?
답변 (2개)
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
2019년 9월 9일
help cd
댓글 수: 3
cd is slow (searches for MATLAB files), changes function scope, and makes debugging harder.
Much better: access data files using fullfile and absolute/relative filenames.
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.
madhan ravi
2019년 9월 9일
Ah :) thanks for the tips.
카테고리
도움말 센터 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!