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!

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 7월 17일
편집: Fangjun Jiang 2020년 7월 17일

1 개 추천

%%
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

This works perfectly, and I have absolutely no idea of what I was doing wrong. xD
Thanks a lot!
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by