1 / 16

Unit 5 Graphical User Interfaces

Unit 5 Graphical User Interfaces. 中華技術學院電子系 蔡樸生 副教授 林盈灝 副教授. Handle Graphics. COMPONENT. OBJECT. HANDLE. MODIFY PROPERTIES. CALLBACK. >> t = 0:0.1:4*pi; >> y = exp(-t/5).*sin(t) >> plot (t,y) >> propedit(gcf). gcf return the handle of current figure. Object. ( Computer Screen).

sveta
Download Presentation

Unit 5 Graphical User Interfaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 5 Graphical User Interfaces 中華技術學院電子系 蔡樸生 副教授 林盈灝 副教授

  2. Handle Graphics COMPONENT OBJECT HANDLE MODIFY PROPERTIES CALLBACK >> t = 0:0.1:4*pi; >> y = exp(-t/5).*sin(t) >> plot (t,y) >> propedit(gcf) gcf return the handle of current figure

  3. Object (Computer Screen) Root Figure Page 504 Uicontrol Uimenu Axis Checkbox Pushbutton Edit Listbox Line Image Text Surface rectangle Patch

  4. Get AND Set • The two function are used to obtain or change Handle Graphics object properties. >> t = 0:0.1:4*pi; >> get ( h,’color’) >> y = exp(-t/5).*sin(t); >> get ( h ) >> h = plot(t,y); >> set ( h,’linewidth’,3) >> set ( h,’Marker’,’o’) >> set ( h,’MarkerSize’,20);

  5. UICONTROLCreate user interface control • Matlab supports 10 unicontrol style. • Format : width / Length • uicontrol ( ‘style’,’oooo’,’position’,[x,y,w,l]); • oooo : push / slide / radio / frame /check / edit • uicontrol (‘style’,’list’,’position’,[200 320 80 30], ‘string’,’1|2|3|4’); • uicontrol (‘style’,’popup’,’position’,[200 370 80 30], ‘string’,’one|two|three|four’);

  6. Type of Uicontrol Popup Push Slide Frame Check Radio Edit List

  7. Create Figure Window & Axes • figure : Create Figure Window. figure('position',[20 20 700 500]); 產生新的視窗,其左下角之座標為[20,20] 長度為700,寬度為500 • axes : Create axes in arbitrary positions. • axes ('position', RECT) • RECT = [left, bottom, width, height](page477) • axes('position',[0.1 0.2 0.8 0.75]); • axis([-20 20 -20 20]);

  8. Axes Normalize

  9. Example - GUI Design clear; figH=figure('position',[20 20 700 500]); axes('position',[0.1 0.2 0.8 0.75]); axis([-15 15 -15 15]); pos1=[60,20,100,30]; h1=uicontrol('style','push','string','Simulation','position',pos1); set(h1,'callback','simulation'); pos2=[335,23,80,24];

  10. Example - GUI Design h2=uicontrol('style','popupmenu','tag','UI9','string','Skew|Gradient|Chain|','position',pos2); pos3=[175,20,50,30]; h3=uicontrol('style','push','string','Clear','position',pos3); set(h3,'callback','mr_parking'); pos4=[240,20,80,30]; h4=uicontrol('style','push','string','Response','position',pos4) set(h4,'callback','responsefig');

  11. Homework (I) • Design a user window interface, the operate environment as following : S 型曲線 四尖擺線 螺旋流線 1

  12. Homework (II) – PID套裝軟体之設計 • 套裝軟体首頁之設計 • 按 ‘進入’, 程式進入之PID套裝軟体畫面 • 可自由設計 P , I , D 三個參數, 並繪製響應圖 • 參考文獻 MATLAB程式設計與應用: CHAPTER 6 : 影像顯示與讀寫 Mastering -MATLAB 6 CHAPTER 28 : Images , Movies , and sound

  13. PID 控制參數之調諧 • x1=0;x2=0;dt=0.01;r=1;step=2000;kcp=200; • tcp=0.44; • kp=kcp*0.6;Td=0.125*Tcp;Ti=0.5*Tcp; • kd=kp*Td;ki=(kp/Ti);pe=r-x1;ie=(r-x1)*dt; • Ziegler-Nichols Tuning : 響應速度加快, 但超越量過大為最大問題 • 自行驗證一個最佳化之調諧參數

  14. Uicontrol – POPUP / LIST • pos1=[335,23,80,24]; • h1= uicontrol ( 'style', 'popup', 'string' , ‘one|two|three|four|','position',pos1); • set(h1,'callback',‘sub_1'); • switch get(h1,'value') • case 1 • statement (subroutine1) ; disp('one') • case 2 • statement (subroutine2) ; disp(‘two') • end

  15. Uicontrol – EDIT • pos2=[Left, Bottom, Width, Height]; • h2=uicontrol('style','edit','string',int2str(initial_x),'position',pos2,'backgroundColor',[1 1 1]); • pos3=[Left, Bottom, Width, Height ]; • h3= uicontrol('style','push','string','Test','position',pos3); • set(h3,'callback',‘sub_3'); • sub_3 subroutine • x=(str2num(get(h2,'string')))

  16. Uicontrol – CHECK/RADIO • pos4=[450,20,80,20]; • h4=uicontrol('style','check','string','Grid on','position',pos4,'value',0); • set(h4,'callback',‘sub_4'); sub_4: • switch get(h4,'value') • case 0 • grid off; • case 1 • grid on; • end

More Related