How to animate a moving figure in matlab?

3 ビュー (過去 30 日間)
Sandeep Reddy Chitti
Sandeep Reddy Chitti 2017 年 9 月 6 日
コメント済み: KSSV 2017 年 9 月 7 日
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
Sandeep Reddy Chitti 2017 年 9 月 6 日
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 Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by