青年梦想家 发表于 2015-7-26 23:56

【奠基经典】MATLAB实用程序案例之沿曲线移动的小球







沿曲线移动的小球
实例:
h0=figure('toolbar','none',...
'position',,...
'name','实例32');
h1=axes('parent',h0,...
'position',,...
'visible','on');
t=0:pi/24:4*pi;
y=sin(t);
plot(t,y,'b')
n=length(t);
h=line('color',,...
'linestyle','.',...
'markersize',25,...
'erasemode','xor');
k1=uicontrol('parent',h0,...
'style','pushbutton',...
'position',,...
'string','开始',...
'callback',[...
'i=1;',...
'k=1;,',...
'm=0;,',...
'while 1,',...
'if k==0,',...
'break,',...
'end,',...
'if k~=0,',...
'set(h,''xdata'',t(i),''ydata'',y(i)),',...
'drawnow;,',...
'i=i+1;,',...
'if i>n,',...
'm=m+1;,',...
'i=1;,',...
'end,',...
'end,',...
'end']);
k2=uicontrol('parent',h0,...
'style','pushbutton',...
'position',,...
'string','停止',...
'callback',[...
'k=0;,',...
'set(e1,''string'',m),',...
'p=get(h,''xdata'');,',...
'q=get(h,''ydata'');,',...
'set(e2,''string'',p);,',...
'set(e3,''string'',q)']);
k3=uicontrol('parent',h0,...
'style','pushbutton',...
'position',,...
'string','关闭',...
'callback','close');
e1=uicontrol('parent',h0,...
'style','edit',...
'position',);
t1=uicontrol('parent',h0,...
'style','text',...
'string','循环次数',...
'position',);
e2=uicontrol('parent',h0,...
'style','edit',...
'position',);
t2=uicontrol('parent',h0,...
'style','text',...
'string','终点的X坐标值',...
'position',);
e3=uicontrol('parent',h0,...
'style','edit',...
'position',);
t3=uicontrol('parent',h0,...
'style','text',...
'string','终点的Y坐标值',...
'position',);


关于本帖内容欢迎大家踊跃讨论,与在下交流!


页: [1]
查看完整版本: 【奠基经典】MATLAB实用程序案例之沿曲线移动的小球