改了一个小程序:
speed=1000;
x=linspace(0,2*pi,speed);
y1=tan(sin(x))-sin(tan(x));
hold on
plot(x,y1);
y2=cos(x);
plot(x,y2);
y1H=line('LineStyle','o','LineWidth',5,...
'MarkerSize',25,'EraseMode','xor',...
'MarkerEdgeColor','b','MarkerFaceColor','r');
y2H=line('LineStyle','o','LineWidth',5,...
'MarkerSize',25,'EraseMode','xor',...
'MarkerEdgeColor','b','MarkerFaceColor','g');
n=length(x);
i=1;
set(gcf,'DoubleBuffer','on');
while 1
set(y1H,'XData',x(i),'YData',y1(i));
set(y2H,'XData',x(i),'YData',y2(i));
drawnow
i=i+1;
if i>n
i=1;
end
end
可以运行,但是有个错误,不知道如何修改?
肯请指教。对于这种多对象的动画应该怎么处理?
??? Invalid handle object.
Error in ==> test at 19
set(y1H,'XData',x(i),'YData',y1(i));