Getting Started | ![]() ![]() |
Graphics User Interfaces
Here is a simple example illustrating how to use Handle Graphics to build user interfaces. The statement
b = uicontrol('Style','pushbutton', ... 'Units','normalized', ... 'Position',[.5 .5 .2 .1], ... 'String','click here');
creates a pushbutton in the center of a figure window and returns a handle to the new object. But, so far, clicking on the button does nothing. The statement
s = 'set(b,''Position'',[.8*rand .9*rand .2 .1])';
creates a string containing a command that alters the pushbutton's position. Repeated execution of
eval(s)
moves the button to random positions. Finally,
set(b,'Callback',s)
installs s
as the button's callback action, so every time you click on the button, it moves to a new position.
Graphical User Interface Design Tools
MATLAB provides GUI Design Environment (GUIDE) tools that simplify the creation of graphical user interfaces. To display the GUIDE Layout Editor, issue the guide
command.
![]() | Finding the Handles of Existing Objects | Animations | ![]() |