How to animate a moving figure in matlab?

3 visualizaciones (últimos 30 días)
Sandeep Reddy Chitti
Sandeep Reddy Chitti el 6 de Sept. de 2017
Comentada: KSSV el 7 de Sept. de 2017
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.

Respuestas (1)

KSSV
KSSV el 6 de Sept. de 2017
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 comentarios
Sandeep Reddy Chitti
Sandeep Reddy Chitti el 6 de Sept. de 2017
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 el 7 de Sept. de 2017
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..

Iniciar sesión para comentar.

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by