MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   动画多个椭圆 (https://www.labfans.com/bbs/showthread.php?t=23650)

poster 2019-12-10 20:41

动画多个椭圆
 
sRMatTemp = [SENSORRANGE]; sRMat = repmat(sRMatTemp, size(obj.landmarks.sensed(:,1), 1)); ellipse(((2*pi*sRMat)/(360/obj.landmarks.sensed(:,4))), obj.landmarks.sensed(:,5) , obj.landmarks.sensed(:,3), obj.landmarks.apparentPositionsST(:,1), obj.landmarks.apparentPositionsST(:,2)); 上面的代码工作正常...一次。问题是我需要设置动画。每次绘制椭圆时,它们都会留在我的屏幕上,并且该图立即变得不可读。

上面的代码也可以很好地用于动画散点图。有什么办法可以将它与椭圆结合使用吗?

我正在使用Mathworks社区站点上的ellipse.m。

fig=figure; axes('NextPlot','add'); set(fig, 'name', 'Animated Graph') l.st=scatter([0],[0],'g.'); set(l.st,'XData',obj.landmarks.apparentPositionsST(:,1),'YData',obj.landmarks.apparentPositionsST(:,2)); drawnow

[B]回答:[/B]

您需要将EraseMode属性设置为xor以便在更新其X / Y数据时,它将删除其旧位置,然后重绘。确保您阅读了此[URL="http://web.archive.org/web/20100516134610/http://www.mathworks.com/support/tech-notes/1200/1204.html#Section%2023"]动画指南[/URL] 。

我写了一个简单的例子来说明动画椭圆。我正在使用上一个问题中关于SO的功能[URL="https://stackoverflow.com/questions/2153768/matlab-to-draw-ellipse-and-ellipsoid/2155456#2155456"]calculateEllipse.m[/URL] 。

step = linspace(50,200,100); figure hAx = axes('XLim',[-250 250], 'YLim',[-250 250], ... 'Drawmode','fast', 'NextPlot','add'); axis(hAx, 'equal') p = calculateEllipse(0, 0, step(1), step(end), step(1)); hLine = line('XData',p(:,1), 'YData',p(:,2), 'EraseMode','xor', ... 'Color','r', 'LineWidth',3); for i=1:numel(step) p = calculateEllipse(0, 0, step(i), step(numel(step)-i+1), step(i)); set(hLine,'XData',p(:,1), 'YData',p(:,2)) %# update X/Y data pause(.05) %# slow down animation drawnow %# force refresh if ~ishandle(hLine), return; end %# in case you close the figure end [URL="https://i.stack.imgur.com/wDzdP.gif"][IMG]https://i.stack.imgur.com/wDzdP.gif[/IMG][/URL]



[url=https://stackoverflow.com/questions/3188142]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 14:18

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