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.
0 个评论
回答(1 个)
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 个评论
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..
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!