Download presentation
Presentation is loading. Please wait.
Published byKeegan Henn Modified over 9 years ago
1
Unit 5 Graphical User Interfaces 中華技術學院電子系 蔡樸生 副教授 林盈灝 副教授
2
Handle Graphics COMPONENTOBJECTHANDLE 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 Root Figure Uicontrol Uimenu Axis (Computer Screen) Line Image Text Surface rectangle Patch Checkbox Pushbutton Edit Listbox Page 504
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
UICONTROL Create 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 List PopupPushSlideFrameCheckRadioEdit
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','positio n',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',p os3); set(h3,'callback','mr_parking'); pos4=[240,20,80,30]; h4=uicontrol('style','push','string','Response','positi on',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),'po sition',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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.