MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manual de usuario Pagina 274

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 500
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 273
9 Examples of GUIDE UIs
9-28
Plot Data
The final task for the plot_button_Callback is to generate two plots. This involves:
Targeting plots to the appropriate axes. For example, this code directs a graph to the
time axes:
plot(handles.time_axes,t,x)
Providing the appropriate data to the plot function
Turning on the axes grid, which the plot function automatically turns off
Note: Performing the last step is necessary because many plotting functions (including
plot) clear the axes and reset properties before creating the graph. This means that
you cannot use the Property Inspector to set the XMinorTick, YMinorTick, and grid
properties in this example, because they are reset when the callback executes plot.
In the following code listing, notice how the handles structure provides access to the
handle of the axes, when needed.
Plot_Button Callback
function plot_button_Callback(hObject, eventdata, handles, varargin)
% hObject handle to plot_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get user input
f1 = str2double(get(handles.f1_input,'String'));
f2 = str2double(get(handles.f2_input,'String'));
t = eval(get(handles.t_input,'String'));
% Calculate data
x = sin(2*pi*f1*t) + sin(2*pi*f2*t);
y = fft(x,512);
m = y.*conj(y)/512;
f = 1000*(0:256)/512;
% Create frequency plot in proper axes
plot(handles.frequency_axes,f,m(1:257))
set(handles.frequency_axes,'XMinorTick','on')
grid on
% Create time plot in proper axes
plot(handles.time_axes,t,x)
set(handles.time_axes,'XMinorTick','on')
grid on
Vista de pagina 273
1 2 ... 269 270 271 272 273 274 275 276 277 278 279 ... 499 500

Comentarios a estos manuales

Sin comentarios