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

📄 cvcn110prod.m

📁 Matalab 源程序,有兴趣的可以下载试试。。。。。。。。
💻 M
字号:
%Simulator of 1D CVCN with only two verbs for each cell: increase(1), decrease (0)
%Rule 30 CVCN
%111 110 101 100 011 010 001 000 
%0 0 0 1 1 1 1 0 
A = [1 1 1; 1 1 0; 1 0 1; 1 0 0; 0 1 1; 0 1 0; 0 0 1; 0 0 0]; 
consequents=[0 1 1 0 1 1 1 0];
size = 101; 
center =(size+1)/2;
Delta = 0.5; 
kappa = 1; 
kI = -8; %increase in consequent
kD = 1/kI; %decrease in consequent

%initial conditions
for i=1:size
    x(i) = 0; 
    x_old(i) = 0; 
end%
x(center) = 1; 

for k=1:size %total steps to evolve
    k
    for i=1:size  
        S = 0; 
        Sfx = 0; 

        for r=1:8 %8 local rules
            i2l = i-1;
            i2r = i+1;
            if i2l<1
                    i2l = size+i2l-1; 
            end%
            if i2r>size
                    i2r = i2r-size; 
            end%
            sall = 1; 
                for i1=-1:1
                    if i1==-1
                        i2 = i2l; 
                    elseif i1==0
                        i2 = i; 
                    else
                        i2 = i2r; 
                    end             
                    %calculate the output by using simplest verb reasoning
                    Delta_x  = x(i2)-x_old(i2); 
                    sI = 1/(1+exp(-Delta_x/Delta));%verb similarity to increase
                    sD = 1/(1+exp(Delta_x/Delta));%verb similarity to decrease
                    sS = 2/(1+exp(kappa*abs(Delta_x))); %verb similarity to  stay
                    a = A(r,i1+2); 
                    if a==0 %decrease
                        s = sD; 
                    elseif a==1 %increase
                        s = sI; 
                    else 
                        s = sS; 
                    end
                    sall = sall*s; 
                end%i1
                S = S+sall; 
                if consequents(r)==0
                    Sfx = Sfx+sall*kD*1/(1+exp(-x(i2))); 
                elseif consequents(r)==1
                    Sfx = Sfx+sall*kI*1/(1+exp(-x(i2))); 
                end
           end%r
           x_new(i) = Sfx/S; 
    end %i
    for i=1:size
        x_old(i) = x(i); 
        x(i) = x_new(i); 
        xx(k,i) = 1/(1+exp(-x(i))); 
    end%
end%k

colormap(hsv(256)); 
%plot the relative amplitude image.
amin = min(min(xx)); 
amax = max(max(xx)); 
if amax - amin < 1e-3
    amin = amin-1e-3; 
    amax = amax+1e-3;     
end
image( (xx-amin)*256/(amax-amin) ); 
set(1,'PaperPosition',[.5 1.5 15.5 15]);
xlabel('cells');
ylabel('iterations');
print -depsc ijcc71b_3x.eps

clear all; 
% n = 5;
% tem = n^3
% tem1 = n^tem

⌨️ 快捷键说明

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