12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

’String’,’0.5’,’Style’,’edit’,...’CallBack’,...’set(hsl,’’Value’’,str2num(get(hed,’’String’’)))’);The value from the edit box is transmitted to the slider when you pressreturn, tab, click outside the edit box, or move the mouse outside theGUI’s window. The slider’s callback must convert the slider’s value—a number—to a string before setting the edit box’s string property. Inprinciple the converse is not true. That is, the slider’s value property canbe passed directly to the edit box’s string property <strong>and</strong> the number willbe displayed automatically as a string. But we have included a numericalconversion using num2str(...,2) to limit the number <strong>of</strong> decimal places<strong>of</strong> the displayed value to 2. (What happens when you type nonnumerictext into the edit box?)The default limits <strong>of</strong> a slider are set to a minimum <strong>of</strong> zero <strong>and</strong> amaximum <strong>of</strong> one. These can be changed via the slider’s min <strong>and</strong> maxproperties: the slider’s value property is scaled proportionally.ListboxListboxes let you choose from among a scrollable list <strong>of</strong> alternatives. Thelist <strong>of</strong> alternatives is set by the listbox’s string property. The optionsfor the format <strong>of</strong> the string are the same as for the axis tick labels (seepage 122); you can specify the alternatives in any <strong>of</strong> the following ways:set(h,’String’,{’Red’;’Green’;’Blue’})set(h,’String’,’Red|Green|Blue’)set(h,’String’,[1;10;100])set(h,’String’,1:3)set(h,’String’,[’Red ’;’Green’;’Blue ’])For example, to bring up a list <strong>of</strong> colour options:h = uicontrol(’pos’,[168 219 89 116], ...’Style’,’listbox’, ...’String’,{’Red’;’Green’;’Blue’});If the list is too wide or high for the listbox, matlab adds scroll sliders:c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!