Fredrik - you can iterate over each element in x, y, and z and either plot the new points, or just update that which has already been plotted with "a little more" data. So we start off as you have done already with
close all;
varv=10;
a = 0.05;
c = 5.0;
t = 0:0.01:varv*2*pi;
x = (a*t/2*pi*c).*sin(t);
y = (a*t/2*pi*c).*cos(t);
z = t/(2*pi*c);
figure(3);
Now, we just create the graphics object that will be used to draw the 3D data, and add labels and a title to the axes.
h = plot3(NaN,NaN,NaN);
xlabel('x');
ylabel('y');
zlabel('z');
title('Conical helix');
The call to plot3 with NaN inputs does not plot anything, it just creates the graphics handle whose data we will update. We now set limits on the axes so that when we do draw, the axes limits remain fixed.
xlim([min(x) max(x)]);
ylim([min(y) max(y)]);
zlim([min(z) max(z)]);
Now we iterate over each point in our data, and update the graphics handle h with the new data, pausing for 1 millisecond to allow the new data to be drawn on the axes.
for k=1:length(x)
set(h,'XData',x(1:k),'YData',y(1:k),'ZData',z(1:k));
pause(0.001);
end
As you can see in the above code, on each iteration of the for loop we update the XData, YData and ZData with a new point.
Try running the above and see what happens!