Animate a line on matlab

前端 未结 1 2051
眼角桃花
眼角桃花 2021-01-23 22:50

I would like to animate a self updating plot on matlab. For example a string vibrating between two ends. All the basic animate functions I have found in the documentation accomp

1条回答
  •  暖寄归人
    2021-01-23 23:03

    What about this:

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

    0 讨论(0)
提交回复
热议问题