[運算] 透過histrogram計算RDF
參考了別人的radical distribution function code修改了許久
所繪出的圖仍然有問題....
這邊前面是取出圖片中每個粒子的2D位置後設為cnt()
然後code如下
感覺是g_Now = hist(Rx,r)./r;這段出問題造成計算出來的平均粒子密度不為1
不知道是否有人可以提點一下.....
http://www.cchem.berkeley.edu/chem195/radial_distribution_8m.html
這邊也有另一組別人寫的code
但相較於下面這串從其他化工系碩論等級的語法我就不太懂裡面需要的參數是什麼了....
我這邊有的參數是從257*257 pixel的圖片中約略2000個粒子的陣列的座標
http://goo.gl/JVrE1O
目前用下面的運算出來整個的平均密度不為1 而且還會decay= =
decay的部份應該是我把邊界條件去掉的緣故
可是我還是不懂為何我算出來平均密度為6左右阿!!!!OTL
先感謝各位的協助了
前幾天老闆才在講說現在業界都是需要會matlab的人才..............
e04都剩不到一年了什麼資源幫忙都沒有還有時間要我生出一堆解決方案.......
唉.......連題目都不確定現在還要突然跳槽去搞模擬
%% Parameters -------------------------------------------------------------
dr = 1; % Step size in unit of nm
X = 20; % Range of g(r) in particle diameter
D = 50; % Ddiameter of a sphere in nm
d = 257/2000; % Pixel to micron ratio
r = 0:dr:X*D; % Distance variable
%% Functions---------------------------------------------------------------
g = zeros(1,length(r)); % Positional pair correlation function
M = length(cnt); % Total number of spheres
%% --------------------------------------
i = 1; % Reference sphere number
n = 0; % Reference sphere count
for i=1:M
N = 1; % N is the number of spheres withn a certain range (minus itself)
j = 1; % Comparing sphere number
for j=1:M
R = sqrt((cnt(i,1)-cnt(j,1))^2 + (cnt(i,2)-cnt(j,2))^2)/d; % Distance between ith and jth sphere
if R <= X*D && R~=0 % Excluding itself
Rx(N) = R; % Obtaining all the distances within the X*D circle
N = N + 1;
end
end
g_Now = hist(Rx,r)./r; % Histogram of Rx using r bin-series
g = g + g_Now; % Adding to the total g(r)
clear Rx; % Clear Rx vector
n = n + 1;
end
toc
plot(r,(g)); hold on
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.55.55
→
10/09 11:22, , 1F
10/09 11:22, 1F
→
10/09 11:23, , 2F
10/09 11:23, 2F