9 views (last 30 days)

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

Matt J
on 22 Jun 2020

darova
on 23 Jun 2020

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

darova
on 24 Jun 2020

Here is the idea

- scale your data
- create an image (fill pixels)
- dilate image to create solid round object (circle)
- use imfindcircles

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909154

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909154

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909163

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909163

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909220

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909220

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909934

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_909934

## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_910177

⋮## Direct link to this comment

https://se.mathworks.com/matlabcentral/answers/552826-calculate-radius-from-scatter-plot#comment_910177

Sign in to comment.