How to create a movie with different plot components?

5 ビュー (過去 30 日間)
Audun Yrke
Audun Yrke 2015 年 1 月 26 日
コメント済み: Audun Yrke 2015 年 1 月 26 日
I am animating some mechanical parts. For each time interval several "mechanical parts" change their positions. My problem is that my program will not clear the plots from the previous time intervals, so at the end the figure becomes a mix of all time intervals.
figure(1)
set(gca,'nextplot','replacechildren');
for t=1:(2*pi/w1)+1
Calculations...
plot([A1(1) A2(1)],[A1(2) A2(2)],'r.')
plot([x1 x2],[y1 y2],'k');
plot([A1(1) x1],[A1(2) y1],'b-')
plot([A2(1) x2],[A2(2) y2],'b-')
plot([P1(1);P2(1)],[P1(2);P2(2)],'go')
hold on
F(t)=getframe;
end
%Make a movie
movie(F,1)
I have used exactly the same method earlier and suceeded, but I have never had more than one plot for each time interval. How can I replace the previous image?
Best regards,
Audun Yrke

採用された回答

Youssef  Khmou
Youssef Khmou 2015 年 1 月 26 日
To clear the previous sample, try :
for t=1:(2*pi/w1)+1
%Calculations...
plot([A1(1) A2(1)],[A1(2) A2(2)],'r.');
hold on;
plot([x1 x2],[y1 y2],'k');
plot([A1(1) x1],[A1(2) y1],'b-')
plot([A2(1) x2],[A2(2) y2],'b-')
plot([P1(1);P2(1)],[P1(2);P2(2)],'go')
hold off;
F(t)=getframe;
end
Adjust the axes for stable sequence.
  1 件のコメント
Audun Yrke
Audun Yrke 2015 年 1 月 26 日
Thank you very much for your answer! There was one combination of hold on/off I had ignored...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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