Matlab动画模拟分子布朗运动的示例

Matlab动画模拟分子布朗运动的示例

%Brownian motion 
clf; 
n=20; 
s=0.02; 
x = rand(n,1)-0.5; 
y = rand(n,1)-0.5; 
h = plot(x,y,'.'); 
axis([-1 1 -1 1]) 
axis square 
grid off 
set(h,'EraseMode','xor','MarkerSize',18) 
grid on; 
title('Press Ctl-C to stop'); 
while 1 
 drawnow 
 x = x + s*randn(n,1); 
 y = y + s*randn(n,1); 
 set(h,'XData',x,'YData',y) 
end



来源:http://www.bime.ntu.edu.tw/~dsfon/Mechanism2/%E5%8B%95%E4%BD%9C%E7%9A%84%E5%90%88%E6%88%90.PDF

你可能感兴趣的:(算法,科学计算)