How to plot points and circles in the same image?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lucas Prata Ferreira
am 17 Jul. 2020
Bearbeitet: Image Analyst
am 17 Jul. 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 Kommentare
Akzeptierte Antwort
Fangjun Jiang
am 17 Jul. 2020
Bearbeitet: Fangjun Jiang
am 17 Jul. 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 Kommentare
Image Analyst
am 17 Jul. 2020
Bearbeitet: Image Analyst
am 17 Jul. 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!