How to plot points and circles in the same image?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Lucas Prata Ferreira
le 17 Juil 2020
Modifié(e) : Image Analyst
le 17 Juil 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!
0 commentaires
Réponse acceptée
Fangjun Jiang
le 17 Juil 2020
Modifié(e) : Fangjun Jiang
le 17 Juil 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 commentaires
Image Analyst
le 17 Juil 2020
Modifié(e) : Image Analyst
le 17 Juil 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!