声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1555|回复: 3

[共享资源] 沿曲线移动的小球!!

[复制链接]
发表于 2006-11-16 12:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
  1. h0=figure('toolbar','none', 'position',[198 56 408 468], 'name','实例32');
  2. h1=axes('parent',h0, 'position',[0.15 0.45 0.7 0.5], 'visible','on');
  3. t=0:pi/24:4*pi; y=sin(t); plot(t,y,'b') n=length(t);
  4. h=line('color',[0 0.5 0.5], 'linestyle','.', 'markersize',25, 'erasemode','xor');
  5. k1=uicontrol('parent',h0, 'style','pushbutton', 'position',[80 100 50 30], 'string','开始',...
  6.     'callback',['i=1; k=1; m=0;',...
  7.         'while 1, if k==0, break, end,',...
  8.         'if k~=0, set(h,''xdata'',t(i),''ydata'',y(i)); drawnow; i=i+1;,',...
  9.         'if i>n, m=m+1; i=1;,',...
  10.         'end; end; end']);
  11. k2=uicontrol('parent',h0, 'style','pushbutton', 'position',[180 100 50 30],...
  12.     'string','停止', 'callback',['k=0; set(e1,''string'',m); p=get(h,''xdata'');,',...
  13.         'q=get(h,''ydata''); set(e2,''string'',p); set(e3,''string'',q)']);
  14. k3=uicontrol('parent',h0, 'style','pushbutton', 'position',[280 100 50 30], ...
  15.     'string','关闭', 'callback','close');
  16. e1=uicontrol('parent',h0, 'style','edit', 'position',[60 30 60 20]);
  17. t1=uicontrol('parent',h0, 'style','text', 'string','循环次数', 'position',[60 50 60 20]);
  18. e2=uicontrol('parent',h0, 'style','edit', 'position',[180 30 50 20]);
  19. t2=uicontrol('parent',h0, 'style','text', 'string','终点的X坐标值', 'position',[155 50 100 20]);
  20. e3=uicontrol('parent',h0, 'style','edit', 'position',[300 30 50 20]);
  21. t3=uicontrol('parent',h0, 'style','text', 'string','终点的Y坐标值', 'position',[275 50 100 20]);
复制代码
转自:中国软件技术网

[ 本帖最后由 ChaChing 于 2009-12-28 15:02 编辑 ]
回复
分享到:

使用道具 举报

发表于 2006-11-20 08:32 | 显示全部楼层
建议修改一下程序,在

  1. 'drawnow;,',...
复制代码


前面增加

  1. 'pause(0.02),',...
复制代码




否则运行太快了,没法看清
 楼主| 发表于 2006-11-21 22:08 | 显示全部楼层
hehe
suffer 建议得很好
发表于 2006-11-25 12:22 | 显示全部楼层
>> 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
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-17 19:17 , Processed in 0.104719 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表