9 Examples of GUIDE UIs
ex_guide_timergui_OpeningFcnex_guide_timergui_OpeningFcn creates the timer using the following code:handles.timer = timer(...
'ExecutionMode', 'fixedRate', ... % Run timer repeatedly
'Period', 1, ... % Initial period is 1 sec.
'TimerFcn', {@update_display,hObject}); % Specify callback
The opening function also initializes the slider Min, Max, and Value properties, and sets
the slider label to display the value: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')))
A call to surf renders the peaks data in the axes, adding the surfaceplot handle to the
handles structure:handles.surf = surf(handles.display,peaks);
Finally, a call to guidata saves the handles structure contents:guidata(hObject,handles);startbtn_Callbackstartbtn_Callback calls timer start method if the timer is not already running:if strcmp(get(handles.timer, 'Running'), 'off')
start(handles.timer);
endstopbtn_Callbackstopbtn_Callback calls the timer stop method if the timer is currently running:if strcmp(get(handles.timer, 'Running'), 'on')
stop(handles.timer);
endperiodsldr_Callbackperiodsldr_Callback is called each time you move the slider. It sets the timer period
to the slider current value after removing unwanted precision:% Read the slider value