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

 Akzeptierte Antwort

Stephen23
Stephen23 am 18 Nov. 2018
Bearbeitet: Stephen23 am 18 Nov. 2018

1 Stimme

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 Kommentare

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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Display Image finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by