MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]关于三叶线动画问题 (https://www.labfans.com/bbs/showthread.php?t=6134)

rnames 2009-01-04 15:16

[求助]关于三叶线动画问题
 
包着询问的态度来的,是不是不太好~~:cool:

原题目是
编写使红色小球沿三叶线 运动的程序。

我的程序如下:
function f=clw_contrail(K,ki)
clc,clf;
sita=0:0.01:2*pi;y=cos(3*sita);
polar(sita,y,'g');axis off;hold on;
h=line(sita(1),y(1));
set(h,'Color',[1 0 0],'Marker', '.', 'MarkerSize',40,'EraseMode','xor');
n=length(sita);i=2;j=1;hold off;
while 1
hold on;polar(sita,y,'g');
h=line(sita(i),y(i));set(h,'Color',[1 0 0],'Marker', '.', 'MarkerSize',40,'EraseMode','xor');
drawnow;hold off; % <22>
pause(0.0001) % <23>
i=i+1;
if nargin==2 & nargout==1
if(i==ki&j==1);f=getframe(gcf);end % <26>
end
if i>n
i=1;j=j+1;
if j>K;break;end
end
end

但是出现了小球的痕迹一直存在的问题,是因为使用hold on,但是如果不使用hold on就无法实现小红球与三叶线同时存在的情况,



:lovely: :lovely: ,怎么办哎

rnames 2009-01-04 15:20

回复: [求助]关于三叶线动画问题
 
:cool: ,上一段有错,嗯嗯~~,
function f=clw_contrail(K,ki)
clc,clf;
sita=0:0.01:2*pi;y=cos(3*sita);
polar(sita,y,'g');axis off;hold on;
h=polar(sita(1),y(1));
set(h,'Color',[1 0 0],'Marker', '.', 'MarkerSize',40,'EraseMode','xor');
n=length(sita);i=2;j=1;hold off;
while 1
hold on;polar(sita,y,'g');
h=polar(sita(i),y(i));set(h,'Color',[1 0 0],'Marker', '.', 'MarkerSize',40,'EraseMode','xor');
drawnow;hold off; % <22>
pause(0.0001) % <23>
i=i+1;
if nargin==2 & nargout==1
if(i==ki&j==1);f=getframe(gcf);end % <26>
end
if i>n
i=1;j=j+1;
if j>K;break;end
end
end


[FONT="Arial Black"][SIZE="7"]这才是我做到最后的版本,问题依旧~~[/SIZE][/FONT]


所有时间均为北京时间。现在的时间是 12:28

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.