필터 지우기
필터 지우기

how to draw circle with different radii in scatter plot?

조회 수: 14 (최근 30일)
Darshan Patel
Darshan Patel 2016년 3월 30일
댓글: Darshan Patel 2016년 3월 30일
I am having three points on scatter plot. taking that point as centre of three circle and draw circles that intercepts each other. please help me its urgent

답변 (2개)

Walter Roberson
Walter Roberson 2016년 3월 30일
See viscircles() instead if you have a newer version of the Image Processing toolkit. Otherwise,
scatter(x(:), y(:), radii(:).^2)
Actually, converting radii to particular size on the screen is more complicated than that, especially if you need something that stays stable when you resize. Markers in scatter plot are designed to stay the same size when you resize the figure. scatter() really isn't suited for what you are doing. Use viscircles instead. Or rectangle()

Roger Stafford
Roger Stafford 2016년 3월 30일
Let P1 = [x1,y1], P2 = (x2,y2), and P3 = [x3,y3] be your three points. Then, interpreting your word 'intercepts' as meaning that the circles should be tangent to one another, do this:
a = norm(P2-P3); b = norm(P3-P1); c = norm(P1-P2);
r1 = (b+c-a)/2; r2 = (c+a-b)/2; r3 = (a+b-c)/2; % <-- This produces tangency
t = linspace(0,2*pi,500);
X1 = P1(1)+r1*cos(t); Y1 = P1(2)+r1*sin(t);
X2 = P2(1)+r2*cos(t); Y2 = P2(2)+r2*sin(t);
X3 = P3(1)+r3*cos(t); Y3 = P3(2)+r3*sin(t);
plot(X1,Y1,'y-',X2,Y2,'r-',X3,Y3,'b-', ...
P1(1),P1(2),'yo',P2(1),P2(2),'ro',P3(1),P3(2),'bo')
axis equal
  댓글 수: 3
Roger Stafford
Roger Stafford 2016년 3월 30일
The a, b, and c quantities are the three distances between the points. The formulas you see for r1, r2, and r3 are the necessary radii that will make all three circles of those respective radii tangent to one another. For example, r1+r2 is equal to c which is just the distance between points P1 and P2, thus producing tangency in the two circles about these two points. The remaining lines of code are a standard way of plotting circles with given centers and radii.
If you want the circles to intersect in more than a single point of tangency, then you need to increase each of these radii. It's up to you how much you want such an increase to be.
Darshan Patel
Darshan Patel 2016년 3월 30일
thank you Roger but i am new to matlab see i am havnig latitudes and longitudes of some places that are L1: 52.1344,-106.648 L2: 37.0001,-122.063 L3: 33.6841,-112.099
now i want to convert them to corresponding x and y coordinate and plot circles with these canters and also implement a concept of trilateration please help its very urgent for me.... thanking you

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

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by