Information Technology Reference
In-Depth Information
z=0.5*(tr(2:ntr)+tr(1:ntr-1)); s=2*mod(ID,2)-1; w0=0;
if mod(ntr,2)==1 w0=w0+s*tr(1); end
for i=1:mm
w0=w0+s*((-1)^i)*abs(tr(1)-z(i));
end
%--------------------------------------------------------------------
eval(['load ',name]); x0=(x0+1)/2; %load the initial state
[m n]=size(x0); i=1:m; j=1:n; % define the array of cells
%--------------------------------------------------------------------
% generate a list of random locations for the Small World model
nloc=round(f*m*n); % number of cells to be connected with distant cells
i_loc=round(1+(m-1)*rand(2,nloc));
j_loc=round(1+(n-1)*rand(2,nloc));
%--------------------------------------------------------------------
% START the iterations (st is the discrete time here)
for st=1:steps
% perform the rewiring for the random locations selected
% in the case of the Small Worlds model (see text)
for p=1:nloc
temp=x0(i_loc(1,p),j_loc(1,p));
x0(i_loc(1,p),j_loc(1,p))=x0(i_loc(2,p),j_loc(2,p));
x0(i_loc(2,p),j_loc(2,p))=temp;
end
%--------------- compute the output of all cells (Matlab implementation of
% the piecewise linear model in (5)
sigm=a*(x0);
sigm=sigm+(x0(i,[2:n,1])+x0(i,[n,1:n-1])+x0([2:m,1],j)+x0([m,1:m-1],j));
w=w0; if mod(ntr,2)==1 w=w0-s*sigm; end
for k=1:mm w=w-s*((-1)^k)*abs(sigm-z(k)); end
% Consider the case of Boolean or continuous cells
%-------------------------------------------------------------------
if dig==1
x0=(sign(w)+1)/2; % implementeaza forma canonica a lui ID
else
x0=(0.5*(abs(w+1)-abs(w-1))+1)/2;
end
%----Consider the case of visualizing or not the cell array -----------
if vis==1
clf
image(64*x0); axis image; title(['Iteration ',num2str(st)])
waitforbuttonpress;
end
%---------------------------------------------------------------------
end
Search WWH ::




Custom Search