MATLAB SIMULINK 7 - GRAPHICAL USER INTERFACE Uživatelský manuál Strana 59

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 500
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 58
Create a Simple UI Programmatically
3-7
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 = source.String;
val = 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
end
Program the Push Buttons
Each of the three 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 plot the data
in current_data. They automatically have access to current_data because they are
nested at a lower level.
Add the following callbacks to your file following the pop-up menu callback and before
the final end statement.
% Push button callbacks. Each callback plots current_data in the
% specified plot type.
function surfbutton_Callback(source,eventdata)
% Display surf plot of the currently selected data.
surf(current_data);
end
function meshbutton_Callback(source,eventdata)
% Display mesh plot of the currently selected data.
mesh(current_data);
Zobrazit stránku 58
1 2 ... 54 55 56 57 58 59 60 61 62 63 64 ... 499 500

Komentáře k této Příručce

Žádné komentáře