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.

set(h,’string’,{’Red’;’Green’;’Blue’;...’Pale Goldenrod’;’Orange’;’yellow’})The item selected within the listbox is accessed via its “value” property.For example, after selecting a colour from the list you can extract itusing the following comm<strong>and</strong>s:>> str = get(h,’string’);>> str(get(h,’value’))ans =’Pale Goldenrod’Popup menuPopup menus are similar to listboxes in that they allow you to choosefrom among a list <strong>of</strong> alternatives, but only one item is shown at a time;the others become visible only when you press the button. Assumingyour listbox is still present from the previous example, you can convertit to a popup menu by typing the following:set(h,’style’,’popup’,...’pos’,[168 219 145 32])We changed the size (position) at the same time to make it look more likea st<strong>and</strong>ard button. The user’s choice is accessed by the popup menu’s“value” property, as for listboxes.34.3 Exclusive Radio ButtonsRadio buttons can be used to <strong>of</strong>fer a choice <strong>of</strong> one, <strong>and</strong> only one, itemfrom among alternatives. Think <strong>of</strong> a car radio with buttons for thedifferent radio channels: when you press one button in, the correspondingchannel only is selected. matlab’s radio buttons do not automaticallybehave this way. You may want to allow more than one radio button tobe pressed at a time. But if you do want exclusive radio buttons youmust implement them with appropriate callbacks. One way to do it isas follows:c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!