MATLAB: Getframe with hold on plotting all previous frames

animationgetframehold onMATLABplotting

I am trying to make an animation of some data from a lab experiment. I need to use the hold on command so that the outline of our test subject and the information from other sets of data is saved onto the plot. The problem is when I use hold on and hold off, everything from previous frames gets plotted. This seems like such a basic problem but I can't find any information related to it.
Thanks for you help, Alex

Best Answer

ALEX,
I think you need to use the delete function after each frame
hold on
p1=plot(loc1(1)+xp,loc1(2)+yp,'r') p2=plot(loc2(1)+xp,loc2(2)+yp,'r') p3=plot(loc3(1)+xp,loc3(2)+yp,'r') p4=plot(loc4(1)+xp,loc4(2)+yp,'r')
plot(prism(:,1),prism(:,2)); axis('tight') hold off
frame = getframe(h); writeVideo(writerObj,frame)
delete(p1); delete(p2); delete(p3); delete(p4);
Related Question