MATLAB: How i can make ech turn of the spiral has a different color.

make ech turn of the spiral has a different color.spiralspiral colors

t=0:0.001:30*pi;
x=t.*cos(t);
y=t.*sin(t);
plot3(x,y,t)

Best Answer

Try this:
t=linspace(0, 30*pi, 10000);
x=t.*cos(t);
y=t.*sin(t);
colors = hsv(length(t));
scatter3(x,y,t, 8, colors, 'filled');
grid on;
xlabel('x', 'FontSize', 20);
ylabel('y', 'FontSize', 20);
zlabel('z', 'FontSize', 20);