How do I access a certain directory?

조회 수: 42 (최근 30일)
James
James 2019년 9월 9일
댓글: madhan ravi 2019년 9월 9일
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.
madhan ravi
madhan ravi 2019년 9월 9일
Ah :) thanks for the tips.

댓글을 달려면 로그인하십시오.

카테고리

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