trouble preventing movie frames overlapping
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (1)
Image Analyst
le 24 Nov 2012
Modifié(e) : Image Analyst
le 24 Nov 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 commentaires
Image Analyst
le 24 Nov 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.
Voir également
Catégories
En savoir plus sur Environment and Settings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!