How to plot points and circles in the same image?

9 visualizzazioni (ultimi 30 giorni)
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!

Risposta accettata

Fangjun Jiang
Fangjun Jiang il 17 Lug 2020
Modificato: Fangjun Jiang il 17 Lug 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 Commenti
Lucas Prata Ferreira
Lucas Prata Ferreira il 17 Lug 2020
This works perfectly, and I have absolutely no idea of what I was doing wrong. xD
Thanks a lot!
Image Analyst
Image Analyst il 17 Lug 2020
Modificato: Image Analyst il 17 Lug 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Image Processing Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by