为多个椭圆设置动画
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
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));
The above code works fine... ONCE. The problem is I need to animate it. Every time I plot the ellipses, they stay on my screen and the graph becomes unreadable instantly.
This is the code above that works fine as well, to animate a scatter plot. Is there a way I can use this with ellipses somehow?
I'm using ellipse.m that's on the Mathworks community site.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将
EraseMode
属性设置为xor
,以便当您更新其X/Y数据时,它将删除其旧位置然后重新绘制。请务必阅读此动画指南。我写了一个简单的例子来说明动画椭圆。我正在使用上一个问题中的函数 calculateEllipse.m这里就这样。
You need to set the
EraseMode
property toxor
so that when you update its X/Y data, it will delete its old location then redraw. Make sure you read this animation guide.I wrote a simple example to illustrate an animated ellipse. I am using the function calculateEllipse.m from a previous question here on SO.