I want to make a gui in which a push button is when pushed will search for a file/folder and when it does it will give that path to another function seperate which will do some processing after it gets a path. So far I did this
function pushbutton2_Callback(hObject, eventdata, handles)
....
....
folder_name=uigetdir('File Selector');
This browse the folder and now I want to give the path of that folder to this function
source_dir = 'here the path of that folder comes';
source_files = dir(fullfile(source_dir, '*.txt/etc'));
In other words if I explain, that pushbutton I used starts executing this function but first it selects a file/directory to input to that function. I tried to use some examples but I am new in making gui so I am not successfull yet. Any help will appreciated. Thank you.
edit..
This is what I was trying to do.
function pushbutton2_Callback(hObject, eventdata, handles)
...
folder_name=uigetdir('File Selector');
global folder_path
folder_path=genpath(folder_name);
%% ftn where it will be used
function abc %% this function is also called in another function.
global folder_path
source_dir = folder_path; %%% where all the files are placed
src_files = dir(fullfile(source_dir, '*.txt'));
then a loop to load all files