![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/588226/image.jpeg)
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
댓글 수: 0
답변 (1개)
Marco Riani
2021년 4월 18일
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/588226/image.jpeg)
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
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!