User`s guide

Time Data Updates from a GUI (GUIDE)
update_display
update_display is the callback for the timer object. It adds Gaussian noise to
the
ZData ofthesurfaceplot:
handles = guidata(hfigure);
Z = get(handles.surf,'ZData');
Z = Z + 0.1*randn(size(Z));
set(handles.surf,'ZData',Z);
Because update_display is not a GUIDE-generated callback, it does not
include
handles as one of its calling arguments. Instead, it accesses the
handles structure by calling
guidata. The callback gets the ZData of the
surface plot from the
handles.surf member of the structure. It modifies
the Z matrix by adding noise using
randn, and then resets the ZD ata of the
surface plot with the modified data. It does not modify the handles structure.
Note Nothing prevents you from adding the h andles structure as an
argument to a non-GUIDE-generated callback, such as
update_display.
However, the handles data the callback receives is a static copy which does
not change when other parts of your code update
handles by calling guidata.
For this reason, the
update_display callback calls guidata to get a fresh
copy of
handles each time it executes.
figure1_CloseRequestFcn
MATLAB calls the figur e1_CloseRequestFcn when you click the close box of
the GUI. The callback cleans up the application before it exits, stopping and
deleting the timer object and then deleting the figure window.
% Necessary to provide this fu nction to prevent timer callback
% from causing an error after GUI code stops executing.
% Before exiting, if the timer is running, stop it.
if strcmp(ge t(ha ndles.timer, 'Runni ng') , 'on')
stop(handles.timer);
end
% Destroy timer
delete(handles.timer)
% Destroy figure
delete(hObject);
10-111