在matlab图形中添加注释后,该图形闪烁太差

在matlab图形中添加注释后,该图形闪烁太差,matlab,animation,annotations,plot,Matlab,Animation,Annotations,Plot,我试图通过以下代码用matlab绘制动画 height = 0.5; for temp=1:1000 clf('reset'); height = 0.5-temp/1000; annotation(gcf,'rectangle',[0.957845238095236-0.1 0.1595238095238094 0.00941666666666667 height],'FaceColor',[1 0 0]); x = rand(1, 20); y = rand(1,

我试图通过以下代码用matlab绘制动画

height = 0.5;
for temp=1:1000
  clf('reset');
  height = 0.5-temp/1000;
   annotation(gcf,'rectangle',[0.957845238095236-0.1 0.1595238095238094 0.00941666666666667 height],'FaceColor',[1 0 0]);
   x = rand(1, 20);
   y = rand(1, 20);
   plot(x, y, '.', 'markersize', 5);
   axis([0 1 0 1]);
   drawnow;
end

如果我隐藏注释代码,它运行得很好,但是如果注释在那里,它闪烁得很差,并且使模拟速度减慢得很差。

您可以注释掉clf'reset';线来解决这个问题…

但我需要在绘制下一帧之前清理图形,有没有替代品来清理它?你试过了吗?如果不使用“保持”或类似功能,则无需清除地物。每次绘制地物时,数据都会被清除。至于注释,您覆盖了它,那么这里有什么问题?是的。对于这个,我不需要澄清。就像你说的,如果我把它扩展到需要保持的东西,没有clf“重置”,如何清理图形谢谢,我只是想我也可以使用保持来清理图形,很抱歉: