trouble preventing movie frames overlapping

2 visualizaciones (últimos 30 días)
Chris ODonnell
Chris ODonnell el 24 de Nov. de 2012
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

Respuestas (1)

Image Analyst
Image Analyst el 24 de Nov. de 2012
Editada: Image Analyst el 24 de Nov. de 2012
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 comentarios
Chris ODonnell
Chris ODonnell el 24 de Nov. de 2012
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 el 24 de Nov. de 2012
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by