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

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 500
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 43
2 How to Create a UI with GUIDE
2-20
This code first retrieves two pop-up menu properties:
String — a cell array that contains the menu contents
Value — the index into the menu contents of the selected data set
The code then uses a switch statement to make the selected data set the current
data. The last statement saves the changes to the handles structure.
% Determine the selected data set.
str = get(hObject, 'String');
val = get(hObject,'Value');
% Set current data to the selected data set.
switch str{val};
case 'peaks' % User selects peaks.
handles.current_data = handles.peaks;
case 'membrane' % User selects membrane.
handles.current_data = handles.membrane;
case 'sinc' % User selects sinc.
handles.current_data = handles.sinc;
end
% Save the handles structure.
guidata(hObject,handles)
Code Push Button Behavior
Each of the push buttons creates a different type of plot using the data specified by
the current selection in the pop-up menu. The push button callbacks get data from the
handles structure and then plot it.
1
Display the Surf push button callback in the MATLAB Editor. In the Layout Editor,
right-click the Surf push button, and then select View Callbacks > Callback.
Przeglądanie stron 43
1 2 ... 39 40 41 42 43 44 45 46 47 48 49 ... 499 500

Komentarze do niniejszej Instrukcji

Brak uwag