Choosing a file in listbox Matlab GUI
<p>I have a listbox of Matlab GUI that displays every files in a folder and a pushbutton. The program is supposed to run if I choose one of a file that displayed in the listbox and click the pushbutton.
Here is my code :</p>

<pre><code> allfiles = dir; %get files
 allname = {allfiles(~[allfiles.isdir]).name};
 set(handles.wavlist, 'String', allname);

 function wavlist_Callback(hObject, eventdata, handles)
     filenames = get(hObject, 'String');
     filechoice = get(hObject, 'Value');
     fileselected = wavnames{filechoice};

 function wavlist_CreateFcn(hObject, eventdata, handles)
     if ispc &amp;&amp; isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
         set(hObject,'BackgroundColor','white');
     end

 function tab1button_Callback(hObject, eventdata, handles)
     [y, fs, nbits, opts] = wavread(fileselected);
</code></pre>

<p>But I get error Undefined function or variable 'fileselected'. Any idea? Thank you...</p>