MATLAB: How to call a function into a pushbutton GUI

gui

Hello ,
I have a GUI with 3 buttons, and a list box.
I would like to update the listbox, when i press a button.
The listbox contents are mat files located in a specific folder.
Here the script of the listbox :
function listbox2_Callback(hObject, eventdata, handles) % hObject handle to listbox2 (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array % contents{get(hObject,'Value')} returns selected item from listbox2 handles.output = hObject; global files global A
set(handles.listbox2,'string',{files.name}); guidata(hObject, handles); contents = cellstr(get(hObject,'String')); %returns listbox1 contents as cell array A=contents{get(hObject,'Value')}
guidata(hObject,handles)
I would like to call this function into the push button
For the moment in pushbutton, i have :
function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved – to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)
global files files = dir(fullfile(pwd,'manoeuvres','Calage_*')); guidata(hObject,handles)
I tried lot a command in order to launch it in the push button but i cant work
How can i manage to do that?
Thx for your reply

Best Answer

OK, my bad , i did not used the good push button ...... :)
So its work with this script inside the pushbutton :
files = dir(fullfile(pwd,'manoeuvres','Calage_*')); set(handles.listbox2,'String',{files.name}); guidata(hObject, handles);
Related Question