Plotting ellipses around the data points and circle around the cluster points

63 次查看(过去 30 天)
I have these points xy
xy = [10 -10; 1 0; -1 0; 0 -1; 0 1 ;11 -10; -1 -1];
scatter(xy(:,1),xy(:,2))
grid on
xlim([-20 20])
ylim([-15 15])
I want to mark a clusters of the data by circle. This is the function that I used incircle()
[C,R] = incircle(A(:,1),A(:,2));
viscircles(C,R,'color','b')
It does not plot proper circle around the data.
After this want to draw ellipse around all data plotEllipses
plotEllipses([0, 0], [10, 0.5])
But I dont know how to rotate ellipse
The result should be:

采纳的回答

Matt J
Matt J 2021-11-30
At the very end of the the Examples tab of
you will find examples for how to plot circles and rotated ellipses.
  1 个评论
NA
NA 2021-12-1
Thank you. I'd like to make sure that I need to use incircle() function, for finding the center.
Also, I should run ellipticalFit.groundtruth two times to draw circle and ellipse.
This is the code I used
A = [10 -10; 1 0; -1 0; 0 -1; 0 1 ;11 -10; -1 -1];
[C,R] = incircle(A(:,1),A(:,2));
Cx = C(1);
Cy = C(2);
angle = -41; %Rotation angle in degrees
[a,b] = deal(18,2); %Major and minor axis radii
gtobj=ellipticalFit.groundtruth(A', [Cx,Cy],[a,b],angle); %Ground truth object
[hTruth,hData]=plot(gtobj,{'Color','m','LineWidth',2},...
{'MarkerFaceColor','c','MarkerEdgeColor','k'}); %Visualize ground truth
hold on
gtobj=ellipticalFit.groundtruth(A', [Cx,Cy],[2,2],angle); %Ground truth object
[hTruth,hData]=plot(gtobj,{'Color','k','LineWidth',1},...
{'MarkerFaceColor','c','MarkerEdgeColor','k'}); %Visualize ground truth
xlim([-20 20])
ylim([-15 15])
grid on

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Polar Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by