I am trying to create an animated plot of triangles and the end result should be ten triangles followed by two bigger triangles followed by a straight line. Using the matlab documentation, I ended up having this, which results an animated sin plot:
h = animatedline;
axis([0 4*pi -1 1])
x = linspace(0,4*pi,2000);
for k = 1:length(x)
y = sin(x(k));
addpoints(h,x(k),y);
drawnow
end
The problem is that the plot is really slow and as soon as I changed y=sin(x(k)) to a triangular form, it got even worst. Is there a better way to do an animated plot or at least to adjust the speed? (if the speed is not dependant on the computer)