How to animate a moving figure in matlab?

3 次查看(过去 30 天)
I want to know how to perform animation of a moving figure using matlab. I know to perform animation of points movement in a plot but I need to know to animate the figure which moves based on center point of a figure. For example I provide some moving commands to center of circle, based on movement of that point the circle should be able to move. Is it possible using matlab. Please let me know. Thank you.

回答(1 个)

KSSV
KSSV 2017-9-6
c = [0 0] ; % center of circle
th = linspace(0,2*pi) ;
r = 0.1;
x = c(1)+r*cos(th) ;
y = c(1)+r*sin(th) ;
h = plot(x,y,'r') ;
axis equal
%%animation
for i = 1:100
c = rand(1,2) ; % center of circle
x = c(1)+r*cos(th) ;
y = c(1)+r*sin(th) ;
set(h,'XData',x,'YData',y) ;
axis([-2 2 -2 2])
drawnow
end
  2 个评论
Sandeep Reddy Chitti
Hello KSSV, you have misunderstood me. I am just referring circle as example. I just want to know if is possible move entire figure based on the movement of a fixed point. Thank you.
KSSV
KSSV 2017-9-7
Yes you just referred a circle....what you want is very much possible. If your concept is not clear with above example..show us pictorial example of what you expect..

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Animation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by