www.pudn.com > 200120237.rar > ball_bounce.m


function ball_bounce() 
%BALL_BOUNCE is a demo of GUI design for the book. 
 
%designed by Professor Dingyu Xue (c), 5 April, 2000 
h_main=figure('Units','normalized','Position',[0.3,0.3,0.5,0.4],... 
   'MenuBar','none','Name','Bouncing Ball Demo',... 
   'NumberTitle','off','Resize','off'); 
h_axis = axes('Units','normalized','Position',[0.12,0.15,0.60,0.7], ... 
	'Tag','axMain','Visible','off','XLim',[0,1],'YLim',[-0.09,1.09]); hold on 
h_button = uicontrol('Style','PushButton','Units','normalized',... 
   'Position',[0.78,0.8,0.2,0.1],'String','Start',... 
   'CallBack','exec_bouncing;'); 
h_rad1 = uicontrol('Style','RadioButton',	'Units','normalized', ... 
   'Position',[0.76 0.64 0.2 0.07],'Tag','rdRadio1',... 
   'BackgroundColor',[0.8,0.8,0.8],'Value',1,... 
   'String','Faster','CallBack','set_speed(1);'); 
h_rad2 = uicontrol('Style','RadioButton',	'Units','normalized', ... 
   'Position',[0.76 0.54 0.2 0.07],'Tag','rdRadio2',... 
   'BackgroundColor',[0.8,0.8,0.8],... 
   'String','Slower','CallBack','set_speed(2);'); 
h_rad3 = uicontrol('Style','RadioButton',	'Units','normalized', ... 
   'Position',[0.76 0.44 0.23 0.07],'Tag','rdRadio3',... 
   'BackgroundColor',[0.8,0.8,0.8],... 
   'String','Default Speed','CallBack','set_speed(3);'); 
h_list = uicontrol('Style','ListBox',	'Units','normalized', ... 
	'Position',[0.77 0.14 0.2 0.25],'String','red|green|blue', ... 
	'Tag','lstColor',	'Value',2,'CallBack','set_speed(4);'); 
h1=line([0,1],-0.09*[1,1]); set(h1,'LineWidth',5); 
h2=line([0,1],1.09*[1,1]); set(h2,'LineWidth',7); 
hMarker=line([0],[1]);  
set(hMarker,'Marker','o','MarkerSize',8,'Color','g',... 
   'Tag','hBall','LineWidth',5); 
uu={[0,1,0],0.05,0.5}; set(h_main,'UserData',uu);