How to select a folder using uigetdir and use folder location later?

After acccessing a particular folder using uigetdir, i want to use folder location later in my code.
In the code mentioned below, how i can get the folder location details in the DOTTED place.
Please help me with that.
Thanks!
directory_name = uigetdir;
File01 = dir(fullfile(directory_name,'*.png'));
---
srcFiles02 = dir('F:\Matlab\Images\Constants\*.png');
---
% Comparision
for i = 1 : image01
Name01 = strcat(..........,File01(i).name);
---

 採用された回答

Stephen23
Stephen23 2018 年 11 月 18 日
編集済み: Stephen23 2018 年 11 月 18 日

1 投票

Do NOT use strcat, you should always use fullfile to build filepaths, just like you did for dir. Like this:
aa = fullfile(directory_name, srcFiles(j).name);
and exactly the same for bb:
D = 'F:\Matlab\Images\Symbols_Constants';
srcFiles2 = dir(fullfile(D,'*.png'));
...
bb = fullfile(D,srcFiles2(j).name);
...

3 件のコメント

Image Analyst
Image Analyst 2018 年 11 月 18 日
If subfolders are searched, like if he wants to use double star in the file pattern passed to dir(), then D is not a constant and he should use
fullFileName = fullfile(srcFiles2(j).folder, srcFiles2(j).name);
image2 = double(imread(fullFileName)); % Read in the second image
Also, in general using single letter variables instead of descriptive ones leads to an alphabet soup mess of a program that is cryptic and hard to follow. However it's good to see an attempt at adding comments was made.
Anonymous18
Anonymous18 2018 年 11 月 19 日
Thank you for the help. I got my problem sloved, with your support.
Anonymous18
Anonymous18 2018 年 11 月 19 日
@Image Analyst: Thank you!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDisplay Image についてさらに検索

質問済み:

2018 年 11 月 18 日

編集済み:

2019 年 1 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by