Radial Distribution function 2D
13 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!