plotting circles
Mostrar comentarios más antiguos
How can I plot circles, same radius and different centers, all in one graph. I used the following command to draw +,o,diamond: plot (x,y,'ro',u,v,'gd',A,B,'b+'); where x,y,u,v,A,B are all row vectors. And I want to add circles to that plot where the o will be the center.
1 comentario
fatima ibrahim
el 29 de Feb. de 2020
function draw_circle1(x,y,R,c)
t =0:0.05:6.28;
x1 = (x +R*cos(t))';
y1= (x +R*sin(t))';
Respuesta aceptada
Más respuestas (3)
Michelle Hirsch
el 29 de En. de 2016
It's counter-intuitive, but this is actually really easy with the rectangle function. From the rectangle documentation :
pos = [2 4 2 2];
rectangle('Position',pos,'Curvature',[1 1])
axis equal
5 comentarios
Image Analyst
el 29 de En. de 2016
Editada: Image Analyst
el 15 de Abr. de 2022
numCircles = 15;
x = 5 + randi(95, numCircles, 1);
y = 5 + randi(95, numCircles, 1);
radius = 2 * ones(numCircles, 1);
viscircles([x, y], radius);
grid on;
axis equal
Ronald Mintz
el 14 de Abr. de 2016
Thanks very much Michelle. Your idea made beautiful concentric circles. viscircles didn't work on my computer because I have version R2011a.
Image Analyst
el 14 de Abr. de 2016
Editada: Image Analyst
el 15 de Abr. de 2022
rectangle() is one of several methods listed in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_create_a_circle.3F> You'll have lots of other nice improvements that they've made over the last 5 years if you upgrade.
numCircles = 15;
x = 5 + randi(95, numCircles, 1);
y = 5 + randi(95, numCircles, 1);
radius = 2 * ones(numCircles, 1);
viscircles([x, y], radius);
grid on;
axis equal
Royi Avital
el 10 de Dic. de 2023
It makes easier when adding it to the legend.
Michelle Hirsch
el 11 de Dic. de 2023
@Royi Avital I think it's more than just adding DisplayName - annotations like rectangle (intentionally) don't show up in legend since they are meant to be annotations, not data. Are you interested in being able to include annotations in legend? If so, please share more about your use case so I make sure we understand what you are thinking.
Chad Greene
el 21 de Ag. de 2014
0 votos
This'll do the job.
Image Analyst
el 20 de En. de 2016
Editada: Image Analyst
el 15 de Abr. de 2022
There is now a function called viscircles(): http://www.mathworks.com/help/images/ref/viscircles.html?s_tid=srchtitle
numCircles = 15;
x = 5 + randi(95, numCircles, 1);
y = 5 + randi(95, numCircles, 1);
radius = 2 * ones(numCircles, 1);
viscircles([x, y], radius);
grid on;
axis equal
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


