Alternating color code in a dotted Circle

2 ビュー (過去 30 日間)
Sonia-Frida Ndifon
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

採用された回答

Cris LaPierre
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
  1 件のコメント
Sonia-Frida Ndifon
Sonia-Frida Ndifon 2021 年 3 月 19 日
Thank you!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by