Stuart N WrigleyBSc(Hons) PhD MIET MBCS SMIEEE MAHEP
Operations and Business Development Manager, UKRI CDT in Speech and Language Technologies and their Applications

Session 3: GUI

Session 1 | Session 2 | Session 3 | Session 4

To get the full benefit of these matlab introduction sessions, try each example in MATLAB. Also, have you completed Sessions 1 and 2? If not, go back to them first.
Matlab's HTML based help - Help Desk - is an invaluable source of information on both functions from the matlab core as well as the GUI programming system Handle Graphics. Each time you come across a new function, look it up in the HTML help. Help Desk can be accessed from the Help menu of the Matlab application.

Introduction
This session is about how to make MATLAB-based Graphical User Interface (GUI) tools.

The Big Picture
The user interface you create is a

To see if your interface is doing a good job, here are two good generic questions:
  1. Do the users always know where they are?
  2. Do they always know where to go next?
Keep returning to these questions, keep thinking about the big picture, and the details fall into place much easier.

GUIs should exhibit simplicity, consistency and familiarity

  1. How long does it take to perform a task the first time?
  2. How long does it take to perform a task once the interface is familiar?
The themes of simplicity, consistency and familiarity bear directly on these two measures.

Simplicity
Simplicity in design is our chief goal. A simple GUI has a clean look and a sense of unity. It’s very easy to add functionality to the GUI you’re building, but if that functionality really doesn’t belong, take it out. Avoid screen clutter, and only present users with choices that advance them toward the completion of the task.

The Dynamic Interface
Much of what we’ve discussed so far is biased by the static world of graphic design. But the world mediated by the computer is a dynamic one, and there are a few more key words to mention. Where you act using the GUI, your actions should be: Immediate, Continuous, and Reversible.

GUI actions should be immediate, continuous and reversible

Design Process

A Complete Example






This is the GUI that represents the final implementation of the design.

Implementing the GUI
There are nine different kinds of uicontrols that can be added:

Just as building GUIs divides into design and implementation, so does the implementation part divide into screen layout and callback handling.
GUI callbacks GUI switchyard callbacks GUI switchyard callbacks using subfunctions

Appropriate use of ButtonDownFcn makes GUIs more powerful

And finally...
Animate with WindowButtonMotionFcn: To animate a response as the mouse is being dragged, use a combination of the callback functions WindowButtonDownFcn, WindowButtonMotionFcn, and WindowButtonUpFcn.

One of the niftier things to do with a MATLAB GUI is animate a calculation on the fly. To do this, you need a function that gets called while the mouse is moving across the screen. This gets a little tricky, but the diagram below explains the situation. Let’s say we want to click, drag, and release a dot on a figure window. When we click down on the dot (a line with a single point, to be specific), we need to pick up the coordinates of the mouse and set the position of the dot accordingly.
Animate with WindowButtonMotionFcn
We can do exactly this with the figure property WindowButtonMotionFcn. But the motion function can only be active when the mouse button is down.

To get a feel for real life GUI implementation, take look at the MAD package. Make sure you are familiar with all the points covered above: session 4 will consist of creating your own GUI to perform a simple sound related task.

Session 1 | Session 2 | Session 3 | Session 4