How to plot points and circles in the same image?

3 visualizaciones (últimos 30 días)
Lucas Prata Ferreira
Lucas Prata Ferreira el 17 de Jul. de 2020
Editada: Image Analyst el 17 de Jul. de 2020
Hi everyone, I'm not very experienced in matlab and am having a hard time trying to find a solution to my problem online, so I come to you. I hope this is not too dumb. ':)
I have the certer coordinates and radii of three circles I need to plot. I also have the coordinates of a series of points I need to check visually if they are in a certain area determined by the circles. What I need in the end up with is something like this:
I can plot the circles and I can plot the points, but I'm not being able to do both. I've tried to use "hold on" between a plot and the other but I can't see exactly why it's not working.
I have drawn the circles using the viscircles function which I'm not very familiar with, so perhaps my problem is here.
I appreciate very much any help possible!

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 17 de Jul. de 2020
Editada: Fangjun Jiang el 17 de Jul. de 2020
%%
c=[0,0;-3 0;2 0];
r=[5;2;3];
viscircles(c,r);
hold on;
plot(10*rand(20,1)-5,10*rand(20,1)-5,'x');
  2 comentarios
Lucas Prata Ferreira
Lucas Prata Ferreira el 17 de Jul. de 2020
This works perfectly, and I have absolutely no idea of what I was doing wrong. xD
Thanks a lot!
Image Analyst
Image Analyst el 17 de Jul. de 2020
Editada: Image Analyst el 17 de Jul. de 2020
Neither do we since you forgot to post your original code, but glad it's working.
viscircles doesn't blow away existing graphics like plot() does. Some functions are like that -- I think line(), xline() and yline() also don't blow away existing content. So it you do plot() first, you don't need hold on:
c=[0,0;-3 0;2 0];
r=[5;2;3];
plot(10*rand(20,1)-5,10*rand(20,1)-5,'x');
viscircles(c,r);
If you use viscircles() first, plot would blow it away, so in that case you would need to put hold on.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by