Radial Distribution function 2D

조회 수: 13 (최근 30일)
Alakesh Upadhyaya
Alakesh Upadhyaya 2021년 8월 4일
댓글: Alakesh Upadhyaya 2021년 8월 4일
I have 792 particle cordiantes (x and y) inside a 2D sphere i.e a circle. I want to find the radial distribution function by taking each of the 792 particles as a tagged center and the average them all in the end. But in doing so I need to bin the particles within certain radius. I know the algorithm but I do not know the syntex. This is my code so far:
data=load('data');
box=100; % size of box
radius=6; % radius of the circle inside the box where the particles are located
npart=500; % number of particles
xcord=100.*data(:,3); % x cordinates
ycord=100.*data(:,4); % ycordinates
xc=100.*0.66297; % x-center since the center is not exactly in 0,0 as it is not perfect circle.
yc=100.*0.32219; % y-center
dr=0.3; % width of the bin
nbins=12./drh; % number of bins =40 in my case
%% Binning the particle
number=zeros(length(xs),1);
for i=1:length(xs)
num=sqrt((xc-xs(i)).^2+((yc-ys(i)).^2)); % This gives the interpartice distance
number(i)=num';
idx=number./dr; %Indexing the distance.
end
end
I want to bin the particles within the 40 bins.
Any help would be appreciated. Thanks
  댓글 수: 2
KSSV
KSSV 2021년 8월 4일
You can use historgram to achieve your binning,
Alakesh Upadhyaya
Alakesh Upadhyaya 2021년 8월 4일
thank you

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

답변 (0개)

카테고리

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

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by