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);
---

 采纳的回答

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 个评论

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.
Thank you for the help. I got my problem sloved, with your support.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Display Image 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by