MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Manuale Utente Pagina 62

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 330
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 61
3 Creating a GUI Programmatically
3-14
Programming the GUI
You use callbacks to program the GUI components. Callbacks are the functions
that execute in response to user-generated events such as a mouse click.
This topic shows you how to write callbacks for the simple GUI, then shows you
how to associate each callback with its component.
“Programming the Pop-Up Menu” on page 3-14
“Programming the Push Buttons” on page 3-15
“Associating Callbacks with Their Components” on page 3-15
Programming the Pop-Up Menu
The pop-up menu enables users to select the data to plot. When a GUI user
selects one of the three data sets, MATLAB sets the pop-up menu
Value
property to the index of the selected string. The pop-up menu callback reads
the pop-up menu
Value property to determine which item is currently
displayed and sets
current_data accordingly.
Add the following callback to your file following the initialization code and
before the final
end statement.
% Pop-up menu callback. Read the pop-up menu Value property
% to determine which item is currently displayed and make it
% the current data. This callback automatically has access to
% current_data because this function is nested at a lower level.
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;
end
Vedere la pagina 61
1 2 ... 57 58 59 60 61 62 63 64 65 66 67 ... 329 330

Commenti su questo manuale

Nessun commento