catch EM
% Cannot evaluate expression user typed
set(handles.plot_button,'String','Cannot plot t');
uicontrol(hObject);
end
The catch block changes the label on the Plot button to indicate that an input value was
invalid. The uicontrol command sets the focus to the field that contains the erroneous
value.
plot_button_Callback
The plot_button_Callback function executes when the user clicks the Plot button.
First, the callback gets the values in the three edit fields:
f1 = str2double(get(handles.f1_input,'String'));
f2 = str2double(get(handles.f2_input,'String'));
t = eval(get(handles.t_input,'String'));
Then callback uses values of f1, f2, and t to sample the function in the time domain and
calculate the Fourier transform. Then, the two plots are updated:
% Create frequency plot in proper axes
plot(handles.frequency_axes,f,m(1:257));
set(handles.frequency_axes,'XMinorTick','on');
grid(handles.frequency_axes,'on');
% Create time plot in proper axes
plot(handles.time_axes,t,x);
set(handles.time_axes,'XMinorTick','on');
grid on
See Also
Related Examples
- “Create a Simple App Using GUIDE” on page 2-2
- “Write Callbacks in GUIDE” on page 7-2
- “Share Data Among Callbacks” on page 11-2
8 Examples of GUIDE UIs