Calculate radius from scatter plot

조회 수: 14 (최근 30일)
yonatan s
yonatan s 2020년 6월 22일
편집: yonatan s 2020년 7월 9일
Hi,
I need to calculate the radius of a circle, ignoring all surrounding particles (image attached). The circle itself consists of many particles (over 100,000). Note that the center of the circle is not at the origin.
Thanks.
EDIT: here is how I solved it:
posn=normal(poscm); %poscm is the coordinates matrix
[k,edges]=histcounts(posn,1e5);
[~,imaxk]=max(k);
R=edges(imaxk+find(k(imaxk:end)==0,1)); %find the first zero value after the maximum
  댓글 수: 5
yonatan s
yonatan s 2020년 6월 23일
It's not perfect, but it seems isoutlier is the right approach.
pdist consumes too much memory.
I tried using some image processing tools, the problem is that axes change when transforming the plot to an image.
Thanks.
Adam Danz
Adam Danz 2020년 6월 23일
If you're still looking for a solution, attach the fig file containing the data, or attach a mat file containing the (x,y) coordinates.

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

답변 (3개)

Matt J
Matt J 2020년 6월 22일
You could try using clusterdata to find the big concentration of points. Then minboundcircle from the File Exchange to get the radius,
  댓글 수: 1
yonatan s
yonatan s 2020년 6월 23일
I have too many particles for that, it requires a lot of memory

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


darova
darova 2020년 6월 23일
Try density function hist3
r = rand(500,1)/5;
t = rand(500,1)*2*pi;
x = [rand(50,1); r.*cos(t)+0.5];
y = [rand(50,1); r.*sin(t)+0.5];
n = 20;
k = hist3([x y],[n n]);
k(k<2) = nan;
pcolor((0:n-1)/n,(0:n-1)/n,k)
hold on
plot(x,y,'.r')
hold off
  댓글 수: 4
Matt J
Matt J 2020년 6월 23일
[centers,radii] = imfindcircles(A,radiusRange)
yonatan s
yonatan s 2020년 6월 23일
the axes change as I transform a plot to an image.

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


darova
darova 2020년 6월 24일
Here is the idea
  • scale your data
  • create an image (fill pixels)
  • dilate image to create solid round object (circle)
  • use imfindcircles
  댓글 수: 5
darova
darova 2020년 6월 25일
There is no need for it
yonatan s
yonatan s 2020년 7월 9일
편집: yonatan s 2020년 7월 9일
Hi darova, went over it again. How do I scale the radius back? If I simply multiply it by the scaling factor it doesnt come out right.

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

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by