MATLAB: Listing files in list box using gui

gui

i have created gui with list box and 1 pushbuttons,now if i click that push button the name of files in my folder must be displayed in listbox(i have 10images in a folder in D drive),ten if i double click the name of file in file selector ,the image should be displayed,please help hoe to do

Best Answer

  • Next use a listbox command
    if(get(hObject, 'Value') == get(hObject, 'Max'))
    filelocation = get(handles.MAT_file, 'string');
    %evaluate the sting as if it were a command. See notes on
    %apostrophies for this one.
    loadfile =['load ''' filelocation ''''];
    evalin('base',loadfile);
    eval(['varlist = who(''-file'' , ''' filelocation ''');']);
    listofvars = [];
    for menuFillItr = 1:length(varlist)
    listofvars = [listofvars varlist(menuFillItr)];
    end
    set(handles.listbox1,'String', listofvars);
    end
    This is just a snippet from some code I wrote a while ago