Mustapha - if you are going to use GUIDE to build your GUI, then rather than using global variables to share information between callbacks, use the handles structure to save the dm or fm data and then access this data from another callback. For example, in your d_mois_Callback callback, do
function d_mois_Callback(hObject, eventdata, handles)
contents=cellstr(get(hObject,'String'));
popdm=contents(get(hObject,'Value'));
popdm;
if(strcmp(popdm,'Janvier'));
dm='01';
elseif ...
end
handles.dm = dm;
guidata(hObject, handles);
Then in your pushbutton callback you would do
function stat_all_Callback(hObject, eventdata, handles)
dm = handles.dm;
fm = ...
end
Note that you may want to check for the existence of these fields (dm, fm, etc.) before you try to access them. Or assign default values to these fields in the OpeningFcn of your GUI. Also, you have duplicate code in your two popup menu callbacks. Since you know
contents=cellstr(get(hObject,'String'));
popfm=contents(get(hObject,'Value'));
then perhaps you could just find popfm in contents and use its index as your dm or fm value (assuming that your list of months are in the usual order).
Best Answer