clf
figure(1)
t=linspace(-5,5,100);
x=sin(t);
y=t.*cos(t); 
z=t.^2-t;
plot3(x,y,z)
grid
hold on 
s=linspace(-5,5,200);
u=5.*sin(s*pi/10);
pause
for n=1:length(s)-1
    t=linspace(s(n),s(n+1),5);
    x=sin(t);
    y=t.*cos(t);
    z=t.^2-t-0.4*ones(size(t));
    plot3(x,y,z,'r','LineWidth',4)
    t=linspace(u(n),u(n+1),5);
    x=sin(t);
    y=t.*cos(t);
    z=t.^2-t+0.4*ones(size(t));
    plot3(x,y,z,'b','LineWidth',4)
    pause(0.01)
end
hold off