Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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

Risposte (1)

Marco Riani
Marco Riani il 18 Apr 2021
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

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by