MATLAB Creating Graphical User Interfaces

(Barry) #1

9 Examples of GUIDE UIs


copyfile(fullfile(docroot, 'techdoc','creating_guis',...
'examples','addr*.*')),...
fileattrib('addr*.*', '+w');
guide address_book.fig;

(^2) In the GUIDE Layout Editor, click the Editor button.
The address_book.m code file opens in the MATLAB Editor.
Calling Syntax
The “address_book_OpeningFcn” on page 9-8 code in address_book.m
interprets the input arguments:



  • If you call the address_book function with no arguments, the UI displays the
    default address book.

  • If you call the address_book function with a pair of arguments (for example,
    address_book('book','my_list.mat')) , the first argument, 'book', is a key
    word that the code looks for in the opening function. If the key word matches, the code
    uses the second argument as the MAT-file for the address book.


address_book_OpeningFcn

function address_book_OpeningFcn(hObject, eventdata, ...
handles, varargin)

% Choose default command line output for address_book
handles.output = hObject;

% Make figure non-dockable
% set(hObject,'DockControls','off')
set(hObject,'WindowStyle','normal')
set(hObject,'HandleVisibility','callback')

% Update handles structure
guidata(hObject, handles);
if nargin < 4
% Load the default address book
Check_And_Load([],handles);
% If first element in varargin is 'book' and the second element is a
% MATLAB file, then load that file
elseif (length(varargin) == 2 && ...
Free download pdf