Creating a GUI M-File

Start by creating an M-file for the example GUI.

  1. At the MATLAB® prompt, type edit. MATLAB opens the editor.

  2. Type or copy the following statement into the editor. This function statement is the first line in the file.

    function simple_gui2
  3. Add these comments to the M-file following the function statement. They are displayed at the command line in response to the help command. They must be followed by a blank line.

    % SIMPLE_GUI2 Select a data set from the pop-up menu, then
    % click one of the plot-type push buttons. Clicking the button
    % plots the selected data in the axes.
    (Leave a blank line here)
  4. Add an end statement at the end of the file. This end statement matches the function statement. Your file now looks like this.

    function simple_gui2
    % SIMPLE_GUI2 Select a data set from the pop-up menu, then
    % click one of the plot-type push buttons. Clicking the button
    % plots the selected data in the axes.
     
    end

  5. Save the file in your current directory or at a location that is on your MATLAB path.

The next section, Laying Out a Simple GUI, shows you how to add components to your GUI.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS