trouble preventing movie frames overlapping

2 ビュー (過去 30 日間)
Chris ODonnell
Chris ODonnell 2012 年 11 月 24 日
Hi!
I am using the following code to make a movie...
for j = 1:10
pcolor(longs,lats,qspeed(:,:,j)), shading flat
annotation('textbox',[0.24 0.54 0.2 0.1],'String',{datestr(date(j),12)},...
'FontSize',16,'LineStyle','none','Color',[1 1 1]);
F(j) = getframe;
end
movie(F,5)
...the problem I have is the textbox containing the date for each frame simply appears on top of the previous one. I need it to replace the previous one but cannot figure out the correct command. Any help greatly appreciated. Thanks

回答 (1 件)

Image Analyst
Image Analyst 2012 年 11 月 24 日
編集済み: Image Analyst 2012 年 11 月 24 日
You need to clear the other text. Use this function:
%=====================================================================
% Erases all lines from the current axes.
function ClearTextFromAxes()
try
axesHandlesToChildObjects = findobj(gca, 'Type', 'text');
if ~isempty(axesHandlesToChildObjects)
delete(axesHandlesToChildObjects);
end
catch ME
errorMessage = sprintf('Error in function ClearTextFromAxes.\nError Message:\n%s', ME.message);
WarnUser(errorMessage);
end
return; % from ClearTextFromAxes
Just call ClearTextFromAxes before you call pcolor().
Or, you might want to call "cla" before you call pcolor since otherwise ALL the images you display become stored in the axes and your process will slow way down as you get to dozens and dozens of images.
  2 件のコメント
Chris ODonnell
Chris ODonnell 2012 年 11 月 24 日
Thanks for the quick response IA. I have tried this and it is still overwritting?? so Im still stuck
Any ideas?
Thanks
Image Analyst
Image Analyst 2012 年 11 月 24 日
It should not. Set a breakpoint on the "if" statement. Then examine axesHandlesToChildObjects to see if it's empty. If it's empty, then you should have no text displayed. If it's not empty, watch the screen as it executes the delete statement and the text should disappear. Last resort is to call cla just before pcolor.

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

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by