User`s guide
7 Save and Run a GUIDE GUI
The GUI files must reside on the MATLAB path or in the current MATLAB
folder where the GUI is run.
If a GUI accepts arguments when it is run, they are passed to the GUI’s
opening function. See “Opening Function” on page 8-25 for m ore information.
Note Consider whether you want to allow more than one copy of the GUI
to be active at the same time. If you want only one GUI to be active, select
Options from the Layout E ditor View menu, then select GUI Allows Only
One Instance to Run (Singleton). See “GUI Options” on page 5-9 for more
information.
From a Test Script
You can test your GUI by executing its callbacks from a M ATLA B s cript or
function. Execu tin g callbacks as you open a GUI also allow s you to initialize
it in a nondefault way. To enable this mode of opening, GUIDE provides a
callback syntax for GUIs, documented i n every code file GUIDE generates:
% gui_name('CAL LBAC K',hObject,eventData,ha ndles,...) calls th e local
% function named CALLBACK i n gui_name.m with t he given input argu men ts.
Here is an example of a script that tests the GUIDE example GUI named
simple_gui. The script loops three times to set the pop-up that specifies data
to plot, and successively “clicks” each of three push buttons to generate a
plot. Run this script from the H elp browser by selecting the following code
and pressing F9:
% Put GUI e xamp les folder on path
addpath(fullfile(docroot,'techdoc', 'creating_guis','example s'))
% Launch the GUI, which is a singleton
simple_gui
% Find handle to hidden figure
temp = get(0,'showHiddenHandles ');
set(0,'showHiddenHandles','on');
hfig = gcf;
% Get the handles structure
handles = guidata(hfig);
% Cycle through the popup values to specif y data to plot
7-12