MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Instrukcja Użytkownika Strona 66

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 330
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 65
3 Creating a GUI Programmatically
3-18
% Create 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;
% Initialize the GUI.
%Change units to normalized so components resize automatically.
set([f,ha,hsurf,hmesh,hcontour,htext,hpopup],...
'Units','normalized');
%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')
% Move the GUI to the center of the screen.
movegui(f,'center')
% Make the GUI visible.
set(f,'Visible','on');
% Callbacks for simple_gui. These callbacks automatically have
% access to component handles and initialized data because
% they are nested at a lower level.
% Pop-up menu callback. Read the pop-up menu Value property
% to determine which item is currently displayed and make it
% the current data.
function popup_menu_Callback(source,eventdata)
% Determine the selected data set.
str = get(source, 'String');
val = get(source,'Value');
% Set current data to the selected data set.
switch str{val};
case 'Peaks' % User selects Peaks
current_data = peaks_data;
case 'Membrane' % User selects Membrane
current_data = membrane_data;
case 'Sinc' % User selects Sinc
current_data = sinc_data;
Przeglądanie stron 65
1 2 ... 61 62 63 64 65 66 67 68 69 70 71 ... 329 330

Komentarze do niniejszej Instrukcji

Brak uwag