MATLAB Creating Graphical User Interfaces

(ff) #1

Files Generated by GUIDE


In this section...
“Code Files and FIG-Files” on page 2-24
“Code File Structure” on page 2-24
“Adding Callback Templates to an Existing Code File” on page 2-25
“About GUIDE-Generated Callbacks” on page 2-26

Code Files and FIG-Files


By default, the first time you save or run your app, GUIDE save two files:


  • A FIG-file, with extension .fig, that contains a complete description of the layout and
    each component, such as push buttons, axes, panels, menus, and so on. The FIG-file is
    a binary file and you cannot modify it except by changing the layout in GUIDE. FIG-
    files are specializations of MAT-files. See “Custom Applications to Access MAT-Files”
    for more information.

  • A code file, with extension .m, that initially contains initialization code and templates
    for some callbacks that control behavior. You generally add callbacks you write for
    your components to this file. As the callbacks are functions, the code file can never be
    a MATLAB script.


When you save your app for the first time, GUIDE automatically opens the code file in
your default editor.

The FIG-file and the code file must have the same name. These two files usually reside in
the same folder, and correspond to the tasks of laying out and programming the app.
When you lay out the app in the Layout Editor, your components and layout is stored in
the FIG-file. When you program the app, your code is stored in the corresponding code
file.

If your app includes ActiveX® components, GUIDE also generates a file for each ActiveX
component.

Code File Structure


The code file that GUIDE generates is a function file. The name of the main function is the
same as the name of the code file. For example, if the name of the code file is mygui.m,

2 How to Create a App with GUIDE

Free download pdf