How to do an animated plot in matlab

后端 未结 3 842
庸人自扰
庸人自扰 2020-11-27 05:51

I was wondering if anyone knew how to do an animation plot of x = (dataset of 1000 points) y = (dataset of 1000 points) plot(x,y)

big problem is these are datasets

3条回答
  •  佛祖请我去吃肉
    2020-11-27 06:15

    Since R2014b, you can work with annimatedline object (doc and how-to) that is meant to handle animated graphs pretty well. Basically, the annimatedline object has a addpoints function that adds new points to the line without having to redefine the existing points, along with a clearpoints function that clears lines for more complex animations.

    Here is an example:

    h = animatedline;
    axis([0,4*pi,-1,1])
    
    x = linspace(0,4*pi,1000);
    y = sin(x);
    for k = 1:length(x)  
        addpoints(h,x(k),y(k));
        drawnow
    end
    

提交回复
热议问题