Why not?
convolution filter
1 1 1
1 9 1
1 1 1
or
1 1 1
1 1 1
1 1 1
mapping function
m(x)=tanh(x/10).*sin(x)
where x=floor(10*x)/10
(1) rulecurr=@(a) tanh(a/10).*sin(a)
(2) rulecurr=@(a) tanh(a/5).*sin(a)
(3) rulecurr=@(a) sig(a-4.5);
(4) rulecurr=@(a)sin(a/3)
matlab code
Code: Select all
%%
global cells cells_old n x y rulecurr async
rind=1;
k=rind;
randrule=1;
randrule=0;
name='nerd';
loadrule
getrule;
n=160;
x=2:n+1;
y=2:n+1;
cells=zeros(n+2,n+2);
async=0;
siz=size(cells);
[x1,x2]=ndgrid(x,y);
xyid=sub2ind(siz,x1,x2);
p0=0.5;
%%
cells=rand(n+2,n+2)*5;
%cells=zeros(n+2,n+2);
% cells(10:15,10:15)=rand(6,6)/2;
cells=torus(cells);
fi=imagesc(cells(xyid)',[0 1]);
rulecurr=@(a) 1-(mod(100*a,100)/100);
% rulecurr=@(a) (mod(a,4))/4;
rulecurr=@(a) tanh(a/10).*sin(a)
px=linspace(-7,7,n+2);
py=linspace(-7,7,n+2);
px=px(x1);
py=py(x2);
stepmax=1000000;
stepnum=1;
intl=6;
div=1;
% px=px(128,1);
% % py=py(1,96);
px=repmat(linspace(px(70,1),px(81,1),n)',1,n);
py=repmat(linspace(py(1,30),py(1,45),n),n,1);
px=repmat(linspace(px(25,1),px(35,1),n)',1,n);
py=repmat(linspace(py(1,135),py(1,150),n),n,1);
tl=sprintf('div=%d',div);
title(tl)
f1='sin(Sinput(xyid)./px)./py;';
f2='mod(Sinput(xyid),px)./py;';
xlabel('px');
ylabel('py');
ax=gca;
set(gca,'XTickLabels',cellstr(num2str(px(ax.XTick,1),3)));
set(gca,'YTickLabels',cellstr(num2str(py(1,ax.YTick)',3)));
while stepnum<stepmax
%%
Sinput=conv2(cells,FIR.Sinput,'same');
Sinput=(floor(div*Sinput)/div);
% cells=rulecurr(Sinput);
Sinput(xyid)=eval(f1);
Sinput(xyid)=eval(f2);
% Sinput(xyid)=mod(Sinput(xyid),px)./py;
cells(xyid)=Sinput(xyid);
cells=torus(cells);
stepnum=stepnum+1;
if mod(stepnum,intl)==0
set(fi,'CData',cells(xyid)')
mv=mean(cells(:));
MAX=max(cells(:));
MIN=min(cells(:));
tl=sprintf(['div=%d,\n',...
'mean=%.2d ' ,...
'min=%.2d max=%.2d \n',...
'%s \n',...
'%s'],div,mv,MIN,MAX,f1,f2);
% set(gca,'Title','1')
title(gca,tl)
drawnow
pause(0.05)
% stepnum=stepnum-intl+1;
end
end