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
Jan 2019년 9월 9일

2 개 추천

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일

0 개 추천

help cd

댓글 수: 3

Stephen23
Stephen23 2019년 9월 9일
편집: Stephen23 2019년 9월 9일
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.

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

제품

릴리스

R2019a

태그

질문:

2019년 9월 9일

댓글:

2019년 9월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by