MATLAB: Diplay wav files in listbox GUI

guilistboxpushbutton

Hi, I need to make a listbox GUI that displays every wav files that I have in a folder. What I want is I just simply put the cursor in one of the wav files at the listbox and click a pushbutton to run my sound processing code. I have this function :
function wavlist_Callback(hObject, eventdata, handles)
function wavlist_CreateFcn(hObject, eventdata, handles)
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function tab1button_Callback(hObject, eventdata, handles)
Like this :
I've tried to put this code in my GUI code but I don't really know how to make it right :
allfiles = dir; %get files
allname = {allfiles(~[allfiles.isdir]).name}
Someone please help me…

Best Answer

set(handles.wavlist, 'String', allname);
and inside wavelist_Callback
wavnames = get(hObject, 'String');
choice = get(hObject, 'Value');
selected_file = wavnames{choice};