Alternating color code in a dotted Circle
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Sonia-Frida Ndifon
el 19 de Mzo. de 2021
Comentada: Sonia-Frida Ndifon
el 19 de Mzo. de 2021
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 comentarios
Respuesta aceptada
Cris LaPierre
el 19 de Mzo. de 2021
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
Más respuestas (0)
Ver también
Categorías
Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!