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 ExchangeFile 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