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

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 330
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 38
Programming the GUI
2-19
Programming the GUI
When you saved your GUI in the previous topic, “Saving the GUI Layout” on
page 2-17, GUIDE created two files: a FIG-file
simple_gui.fig that contains
the GUI layout, and an M-file
simple_gui.m that contains the code that
controls the GUI. But the GUI didn’t do anything because there was no code in
the M-file to make it work. This topic shows you how to add code to the M-file
to make it work. There are three steps:
“Generating Data to Plot” on page 2-19
“Programming the Pop-Up Menu” on page 2-21
“Programming the Push Buttons” on page 2-23
Generating Data to Plot
This topic shows you how to generate the data to be plotted when the user
clicks a button. This data is generated in the opening function. The opening
function is the first callback in every GUIDE-generated GUI M-file. You can
use it to perform tasks that need to be done before the user has access to the
GUI.
In this example, you add code that creates three data sets to the opening
function. The code uses the MATLAB functions
peaks, membrane, and sinc.
1 Display the opening function in the M-file editor. If the GUI M-file,
simple_gui.m, is not already open in your editor, open it by selecting M-file
Editor from the View menu. In the editor, click the function icon on the
toolbar, then click
simple_gui_OpeningFcn in the pop-up menu that
displays.
Zobrazit stránku 38
1 2 ... 34 35 36 37 38 39 40 41 42 43 44 ... 329 330

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

Žádné komentáře