User`s guide
Time Data Updates from a GUI (GUIDE)
How the GUI Imple
ments the Timer
Each callback in
the G UI either creates, m odifies, starts, stops, or destroys
the timer object
. The following sections describe what the callbacks do.
• “ex_guide_tim
ergui_OpeningFcn” on page 10-109
• “startbtn_Ca
llback” on page 10-110
• “stopbtn_Cal
lback” on page 10-110
• “periodsldr
_Callback” on page 10-110
• “update_dis
play” on page 10-111
• “figure1_C
loseRequestFcn” on page 10-111
ex_guide_timergui_OpeningFcn
ex_guide_
timergui_OpeningFcn
creates the timer using the following code:
handles.timer = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer r epeatedly
'Period', 1, ... % Initial period is 1 sec.
'TimerFcn', {@u pdat e_display,hObject}); % Specify callbac k
The open
ing function also initializes the slider
Min, Max,andValue properties,
and sets
thesliderlabeltodisplaythevalue:
set(handles.periodsldr,'Min',0.01,'Max' ,2)
set(handles.periodsldr,'Value',get( handles.timer('Period'))
set(handles.slidervalue,'String',.. .
num2str(get(handles.periodsldr,'Value' )))
Acal
lto
surf renders the pea ks data in the axes, adding the surfaceplot
hand
le to the h andles structure:
handles.surf = surf(handles.display,peaks);
Fin
ally, a call to
guidata saves the handles structure contents:
guidata(hObject,handles);
10-109