MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuale Utente Pagina 59

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 330
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 58
Initializing the GUI
3-11
Initializing the GUI
When you make the GUI visible, it should be initialized so that it is ready for
the user. This topic shows you how to:
Make the GUI behave properly when it is resized by changing the component
and figure units to
normalized.
This causes the components to resize when the GUI is resized. Normalized
units map the lower left corner of the figure window to
(0,0) and the upper
right corner to (
1.0, 1.0).
Generate the data to plot.
The example needs three sets of data:
peaks_data, membrane_data, and
sinc_data. Each set corresponds to one of the items in the pop-up menu.
Create an initial plot in the axes
Assign the GUI a name that appears in the window title
Move the GUI to the center of the screen
Make the GUI visible
1 Replace this code in your M-file:
% Make the GUI visible.
set(f,'Visible','on')
with this code:
% Initialize the GUI.
% Change units to normalized so components resize automatically.
set([f,hsurf,hmesh,hcontour,htext,hpopup],'Units','normalized');
% Generate the data to plot.
peaks_data = peaks(35);
membrane_data = membrane;
[x,y] = meshgrid(-8:.5:8);
r = sqrt(x.^2+y.^2) + eps;
sinc_data = sin(r)./r;
% Create a plot in the axes.
current_data = peaks_data;
surf(current_data);
% Assign the GUI a name to appear in the window title.
set(f,'Name','Simple GUI')
Vedere la pagina 58
1 2 ... 54 55 56 57 58 59 60 61 62 63 64 ... 329 330

Commenti su questo manuale

Nessun commento