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.

The two inner frames are labeled by placing text style uicontrols with thestrings Personal Details <strong>and</strong> Tax Details at appropriate positions.Too many frames clutter the GUI. It is <strong>of</strong>ten better to use space betweengroups <strong>of</strong> controls to divide them into logical groups.SliderSliders are designed to allow input <strong>of</strong> a value between two limits. Youinput a value by clicking on the central bar <strong>and</strong> dragging it; by clickinganywhere between the central bar <strong>and</strong> the end <strong>of</strong> the slider, resultingin a big jump; or by clicking on the arrows at the ends <strong>of</strong> the slider,resulting in a little jump. Fiddle with the following slider to see how itbehaves:h = uicontrol(’style’,’slider’);set(h,’pos’,[50 200 450 40])set(h,’callback’,’disp(get(h,’’value’’))’)This slider has its callback property set so as to display the value <strong>of</strong> theslider in the comm<strong>and</strong> window. The callback is executed when (1) yourelease the central bar, (2) you click on the blank area, or (3) you clickon the arrow.You may want to display the value <strong>of</strong> a slider in an edit box, or to usethe value typed into an edit box to alter the position <strong>of</strong> the slider. Todo this you have to get an edit box <strong>and</strong> a slider to talk to each other toreveal their properties. The edit box must have a callback that tells theslider its string property, <strong>and</strong> the slider must have a callback that tellsthe edit box its value property. The following piece <strong>of</strong> code achievesthis effect:clfhsl = uicontrol(’Position’,[200 260 200 20], ...’Style’,’slider’,’Value’,0.5,...’CallBack’,...’set(hed,’’String’’,num2str(get(hsl,’’value’’),2))’);hed = uicontrol(’BackgroundColor’,[1 1 1], ...’Position’,[200 240 70 20], ...c○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!