To this code I want to add the property that every new turn renderes a new color in the plot

1 次查看(过去 30 天)
To this code I want to add the property that every new turn renderes a new color in the plot.
nturns = 8;
t=linspace(0, nturns*2*pi, 10000);
x=t.*cos(t);
y=t.*sin(t);
z=t;
colors = hsv(length(t));
plot3(x,y,t)
xlabel('x')
ylabel('y')
zlabel('t')
view(3)
h = get(gca,'zlabel');%handle
f = get(gca,'xlabel');
g = get(gca,'ylabel');
set(h,'Rotation',0,'VerticalAlignment','middle');
set(f,'Rotation',0,'HorizontalAlignment','center')
set(g,'Rotation',0,'HorizontalAlignment','right')
grid on

回答(1 个)

Marco Riani
Marco Riani 2021-4-18
Hi Robert,
The above is a preview (I hope this is what you asked)
Here is the code (done for example for the case nturns=5)
close all
nturns = 5;
Colors={'r' 'g' 'b' 'c' 'k'};
hold('on')
for ii=1:nturns
t=linspace((ii-1)*2*pi, ii*2*pi, 10000);
x=t.*cos(t);
y=t.*sin(t);
z=t;
plot3(x,y,t,'Color',Colors{ii})
end
xlabel('x')
ylabel('y')
zlabel('t')
view(3)
h = get(gca,'zlabel');%handle
f = get(gca,'xlabel');
g = get(gca,'ylabel');
set(h,'Rotation',0,'VerticalAlignment','middle');
set(f,'Rotation',0,'HorizontalAlignment','center')
set(g,'Rotation',0,'HorizontalAlignment','right')
grid on

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by