trouble preventing movie frames overlapping
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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
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 Exchange에서 Environment and Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!