沿曲线移动的小球!!
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',);
转自:中国软件技术网
[ 本帖最后由 ChaChing 于 2009-12-28 15:02 编辑 ] 建议修改一下程序,在
'drawnow;,',...
前面增加
'pause(0.02),',...
等
否则运行太快了,没法看清 hehe
suffer 建议得很好 >> role
Warning: Setting marker type based on 'LineStyle' property
'Marker' and 'LineStyle' have been made separate properties
Use 'Marker' property to remove this warning.
> In role at 11
??? Invalid handle object.
??? Error while evaluating uicontrol Callback.
是不是我的版本问题
matlab7.0.1
页:
[1]