MATLAB: Displaying files using a Listbox

guiguidelistbox

Using GUIDE, I have a listbox that I wish to use to display a folder of files, then have the user select a file from the box, then click another pushbutton to run the selected file. I was looking at http://www.mathworks.com/help/techdoc/creating_guis/f6-7446.html#f6-11263 but was confused where the path to the directory goes or how I add that.
Under the section Specifying the Directory, I see list_box('create','path_to_folder') but am unsure if that is what I'm looking for.
Thanks for the help

Best Answer

Is the folder of files you wish to display going to be hardcoded into the GUI, or do you wish to have the user select the folder too?
EDIT
Here is an example how to do this. The following code works on my machine. I think you will put the stuff which gets the directory name in the listbox createfcn or the figure creatfcn. I don't use GUIDE anymore so I may be wrong about that. Give it a try and let me know what happens. Note, I commended the lines of importance to your problem.
function [] = GUI_LST_DIR()
S.fh = figure('units','pixels',...
'position',[500 500 200 260],...
'menubar','none',...
'name','GUI_1',...
'numbertitle','off',...
'resize','off');
D = dir('C:\Users\matt fig\Documents\MATLAB'); % Here put your dir name.
D = {D(:).name};
D = D(~cellfun('isempty',strfind(D,'m')));
S.ls = uicontrol('style','list',...
'unit','pix',...
'position',[10 60 180 180],...
'min',0,'max',2,...
'fontsize',14,...
'string',D); % Populate the string with D.
S.pb = uicontrol('style','push',...
'units','pix',...
'position',[10 10 180 40],...
'fontsize',14,...
'string','Run File',...
'callback',{@pb_call,S});
function [] = pb_call(varargin)
% Callback for pushbutton, runs the selected M-File
S = varargin{3}; % Don't worry about this in GUIDE GUI.
% Instead of S.ls, use GUIDATA to get handle to listbox
C = get(S.ls,{'string','value'});
mfl = C{1}(C{2}); % The M-File string name.
eval(mfl{1}(1:end-2)) % Run the M-File