radialDistribution2​D.m

버전 1.1.0.0 (5.08 KB) 작성자: adi
calculates radial Distribution in 2D
다운로드 수: 1.3K
업데이트 날짜: 2015/8/22

라이선스 보기

input:
% ~~~~~~
% switchVal - operation of the finction
% initialize=0;
% sample=1;
% results=2;
% plot = 3;
%
% gR - the output struct contaning the histogram
% (shuold be created with "gR = struct;" before initialization
%
% coords - x,y coordinates of partical centers
% first row x, second row y
%
% Lx - x size of area to calculate
% Ly - y size of area to calculate
%
% NumOfBins - number of bins in the final histogram
%
% output:
% ~~~~~~~
% gR is a histogram struct contaning:
% gR.count - total number of object counted
% gR.range - x axis range for the histogram
% gR.increment - increment of x axis
% gR.saveFileName - name of saved dat file
%
% method:
% ~~~~~~~
% the RDF is calculated by binnig all pair partical distances into
% a histogram, and normalizing each bin with it's Ideal gas number of
% particals.
% when binning the pair distances, we take into acount Periodic
% Boudary Conditions (PBC)
% finaly, to ansure that when r->infinity : RDF ->1 , we
% normalize by multiplying RDF*2/(N-1) where N is the number of
% particals.
% for more information http://www2.msm.ctw.utwente.nl/sluding/TEACHING/APiE_Script_v2011.pdf
% page 48 - "Radial distribution function"

-------
|important|
-------
this function uses the functions "histogram", "distPBC2D"
"histogram" can be found here: http://www.cchem.berkeley.edu/chem195/histogram_8m.html#aedd379efd57ae78820ad8787bfab0cce
"distPBC2D" can be found here: http://www.mathworks.com/matlabcentral/fileexchange/46575-distpbc2d-m
%% example %%
example for the code above. please note that "radialDistribution2D" uses the functions "histogram" and "distPBC2D":
"histogram" can be found here: http://www.cchem.berkeley.edu/chem195/histogram_8m.html#aedd379efd57ae78820ad8787bfab0cce
"distPBC2D" can be found here: http://www.mathworks.com/matlabcentral/fileexchange/46575-distpbc2d-m

make sure these functions are in your path before you run this code.

coords = [rand(1,100); rand(1,100)]; % in this example we will calculate
% the RDF for a random sett of 100 coordinates. first row is x coordinates,
% second row is y coordinates.

Lx = 1; % board size
Ly = 1;

NumOfBins = 100; % How many bins you want in your RDF histogram. this is
% the RDF's resolution.

gR = struct; % create a struct, this is where our RDF
%(radial distribution function) will be at the end of this calculation.

% initialize gR struct
gR = radialDistribution2D(0,gR,coords,Lx,Ly,NumOfBins);

% Loop over pairs and determine the distribution of distances
gR = radialDistribution2D(1,gR,coords,Lx,Ly,NumOfBins);

% Normalize distance distribution histogram to get the RDF
gR = radialDistribution2D(2,gR,coords,Lx,Ly,NumOfBins);

% plot Result
gR = radialDistribution2D(3,gR,coords,Lx,Ly,NumOfBins);

your results are saved in "gR" struct. "gR.values" has the bins (x axis) of the RDF. "gR.histo" has the histogram (y axis) of the RDF.

인용 양식

adi (2024). radialDistribution2D.m (https://www.mathworks.com/matlabcentral/fileexchange/46576-radialdistribution2d-m), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2013b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Thermal Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.0

just changed the description
added an example to the discription

1.0.0.0