12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1. Use graphical elements that serve no other purpose than to allowthe user to interact (virtual buttons, switches, knobs, sliders, popupmenus, <strong>and</strong> so on). (See demo for examples <strong>of</strong> these.)2. Use graphical elements that perform a dual function: display data<strong>and</strong> interaction. For example, a plotted line can both display data<strong>and</strong> can alter data when a user clicks on the line <strong>and</strong> drags it to anew position. (See sigdemo1 in the signal processing toolbox foran example.)3. Use mouse-downs, drags, <strong>and</strong> mouse-ups anywhere within the Figureto perform an action. (For example, typing rotate3d wheneveryou are displaying a three-dimensional plot allows you to click <strong>and</strong>drag to change the viewpoint.)The first group <strong>of</strong> GUIelements (buttons, etc.) are the easiest to workwith, so we deal with those first.There are three GUI-specific graphical objects in matlab: uicontrols,uimenus, <strong>and</strong> uicontextmenus.These are at the same level as Axes objects in matlab’s object hierarchy.They are children <strong>of</strong> Figures; they have no children. Their appearance<strong>and</strong> behaviour are defined by their property values. We first look at thedifferent styles <strong>of</strong> uicontrol. Then we will look at how you can programa uicontrol to do something by setting its callback property. Finally,we will go through the various uicontrols in a bit more detail, beforeconsidering uimenus. Uicontextmenus control matlab’s behaviour whenyou do a “right-click” (or equivalent menu-getting click on your system)on a graphical object. They will not be described here, but you can finda description in the helpdesk entry under H<strong>and</strong>le Graphics Objects.If you type uicontrol, you will get matlab’s default uicontrol (weassign its h<strong>and</strong>le to h for later use):h = uicontrol;As usual, get(h) will give you a list <strong>of</strong> properties for this object. Animportant property for uicontrols is the style property. The style <strong>of</strong> thisobject is>> get(h,’style’)ans =pushbuttonc○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!