How do I access a certain directory?

43 ビュー (過去 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
  1 件のコメント
madhan ravi
madhan ravi 2019 年 9 月 9 日
+1

サインインしてコメントする。


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 Center および File ExchangeFile Operations についてさらに検索

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by