how not to delete one figure using clf?

4 ビュー (過去 30 日間)
Sierra
Sierra 2022 年 12 月 26 日
回答済み: Jan 2022 年 12 月 26 日
I want to plot animation with a background image.
but for animation, i used clf in for loop.
so the backgorund image is deleted because of clf.
here is my code.
open('example.fig')
for i = 1:length(TX)
clf
plot3(TX(1,i),TX(2,i),TX(3,i),'o','markerfacecolor','r','markersize',10,'markeredgecolor','k');
hold on
VVS = VV{i};
VV_lon = VVS(1,:);
VV_lat = VVS(2,:);
VV_alt = VVS(3,:);
plot3(VV_lon,VV_lat,VV_alt,'b--')
drawnow; pause(0.1)
end
thanks.
  1 件のコメント
Voss
Voss 2022 年 12 月 26 日
Does removing clf produce the desired result? If not, how not?

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

回答 (1 件)

Jan
Jan 2022 年 12 月 26 日
clf clears the contents of the current figure. If you do not want this, remove clf.
Maybe all you want is to clear the current axes. Then use gca instead. This causes some flickering. Animating objects is smoother, if they are not created repeatedly, but the values are adjusted.
axesH = axes('NextPlot', 'add'); % as: hold on
H1 = plot3(TX(1,1), TX(2,1), TX(3,1), 'o', ...
'markerfacecolor','r','markersize',10,'markeredgecolor','k');
for i = 1:length(TX)
pause(0.1); % No additional drawnow required
set(H1, 'XData', TX(1,1), 'YData', TX(2,1), 'ZData', TX(3,1));
end

カテゴリ

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