Alternating color code in a dotted Circle
2 ビュー (過去 30 日間)
古いコメントを表示
Sonia-Frida Ndifon
2021 年 3 月 19 日
コメント済み: Sonia-Frida Ndifon
2021 年 3 月 19 日
I have plotted a circle with red dots using the sine and cosine functions , but I am trying to edit it such that every other dot color is blue. Here is my code
t=0:0.1:2*pi;
figure
hold on
for i=1:numel(t)
sine=sin(t);
cosine=cos(t);
end
plot(sine,cosine,'r.')
xlim([-1.25 1.25])
ylim([-1 1])
axis equal
0 件のコメント
採用された回答
Cris LaPierre
2021 年 3 月 19 日
All markers in a series will have the same color, so the best approach I can think of is to plot two separate series, one with red markers and the other with blue.
t=0:0.1:2*pi;
figure
sine=sin(t);
cosine=cos(t);
plot(sine(1:2:end),cosine(1:2:end),'r.')
hold on
plot(sine(2:2:end),cosine(2:2:end),'b.')
hold off
xlim([-1.25 1.25])
ylim([-1 1])
axis equal
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!