MATLAB: If I change the folder names in the popup menu and i need to get the files in that folder to the list box and similar if i change to other folder , that folders files should come

guiMATLABmatlab gui

  1. I am not clear how to change files in list box w.r.t that folder
Kindly please help me with this
Thanks
Lokesh

Best Answer

ph = handles.YourPopup;
lh = handles.YourListbox;
selection_index = ph.Value;
if ~isempty(selection_index)
user_chosen_folder = ph.String{selection_index};
dinfo = dir(user_chosen_folder);
dinfo([dinfo.isfolder]) = []; %only want file names
filenames = {dinfo.name}; %names of the files
lh.String = filenames; %put the names in the listbox
drawnow()
end