⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enttim.m

📁 一个利用元胞自动机进行生态仿真的matlab程序
💻 M
字号:
function ah=enttim(X,lns)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Calculate time-entropy of CA configuration
%
%
%	Fist Coded			5   June  1998
%	Last Modefied		5   June  1998
%
%	Copyright (c)
%	T. Suzudo JAERI-CAIL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Argument
% X	  : CA Matrix x time
% lns ; state per cell
%
% Variables
%  ah	: average time entropy
%  tn: total number per state
%  nx: x-number of local sites
%  ny: y-number of local sites
%  ps : number of state per patch

% Matrix size
nlx = size(X,1);
nly = size(X,2);
tfin = size(X,3);
if ~(nlx==nly) erorr('ERROR: Rectangle Matrix is not allowed.')
else nl=nlx;
end

sk=[1:2:tfin];
sk1=[2:2:tfin];

tp = fix(size(X,3)/2);

Y=zeros(nl,nl,tp);

% how many states?
% We take 2 patchs, so
ps = lns^2;

% Calculate the probability
Y = X(:,:,sk) + 2*X(:,:,sk1);
h = zeros(nl);
for ii=0:ps-1
	tn = sum(~(Y-ii),3);
	h = h - (tn/tp).*log(max(tn/tp,0.001))/log(ps);
end
ah=mean(mean(h));

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -