User`s guide

Share Data Among a GUI’s Callbacks
Slider Values. In this example, both the slider callback, slide r_c allback,
and the edit text callback,
edittext_callback, retrieve the GUI data
structure
slider which hold previous and current values of the slider. They
then save the v alue,
slider.val to s lide r.previous_val before retrieving
thenewvalueandassigningitto
slider.val. Before returning, each callback
saves the
slider structure to GUI data.
slider = guidata(fh); % Get GUI data.
slider.previous_val = slider.va l;
slider.val = str2double(get(hObject,'String'));
...
guidata(fh,slider) % Save GUI data before returni ng.
Both callbacks use the guidata function to retrieve and save the s lider
structure as GUI data.
13-23