User`s guide
GUI with Multiple Axes (GUIDE)
%tisnotanumber
set(handles.plot_button,'String','t is not numeric')
elseif length(t) < 2
%tisnotavector
set(handles.plot_button,'String','t must be vector')
elseif length(t) > 1000
% t is too long a vector to plot clearly
set(handles.plot_button,'String','t is too long')
elseif min(diff(t)) < 0
% t is not monotonically increasing
set(handles.plot_button,'String','t must increase')
else
% All OK; Enable the Plot button with its original name
set(handles.plot_button,'String','Plot')
set(handles.plot_button,'Enable','on')
return
end
% Found an input error other than a bad expression
% Give the edit text b ox focus so user can correct the error
uicontrol(hObject)
catch EM
% Cannot evaluate expression u ser typed
set(handles.plot_button,'String','Cannot plot t')
% Give the edit text box focus so user can correct the error
uicontrol(hObject)
end
The edit text callbacks execute when the user enters te xt in an edit box and
presses Return or clicks elsew h ere in the GU I. Even if the user immediately
clicks the Plot button, the edit text callback executes before the plot button
callback activates. When a callback receives invalid input, it disables the
Plot button, preventing its callback from running. Finally, it restores focus
to itself, selecting the text that did not validate so that the user can re-enter
avalue.
As an example, here is the GUI’s response to input of a time vector,
[126
4579], that does not monotonically increase.
10-13