元胞自动机程序.txt资料文档下载

上传人:b****1 文档编号:13164618 上传时间:2022-10-07 格式:TXT 页数:16 大小:17.69KB
下载 相关 举报
元胞自动机程序.txt资料文档下载_第1页
第1页 / 共16页
元胞自动机程序.txt资料文档下载_第2页
第2页 / 共16页
元胞自动机程序.txt资料文档下载_第3页
第3页 / 共16页
元胞自动机程序.txt资料文档下载_第4页
第4页 / 共16页
元胞自动机程序.txt资料文档下载_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

元胞自动机程序.txt资料文档下载

《元胞自动机程序.txt资料文档下载》由会员分享,可在线阅读,更多相关《元胞自动机程序.txt资料文档下载(16页珍藏版)》请在冰豆网上搜索。

元胞自动机程序.txt资料文档下载

end));

X(k+1,n)=1;

set(H,'

CData'

X);

pause(0.1);

k=k+1;

file3:

functionCA_sim_cloud;

%ʹ��Ԫ���Զ���ģ��������ǵ���ͼ

%

%reference:

%Piazza,E.;

Cuccoli,F.;

%CellularAutomataSimulationofCloudsinSatelliteImages,

%GeoscienceandRemoteSensingSymposium,2001.IGARSS'

01.

%IEEE2001InternationalVolume4,9-13July2001Page(s):

%1722-1724vol.4DigitalObjectIdentifier10.1109/IGARSS.

%2001.977050

time=888;

%����ִ�в���

M=240;

N=320;

S=round(rand(M,N)*15);

p=[1,2,1,6,6,1,2,1];

p=sum(tril(meshgrid(p)),2)/20;

rand('

state'

0);

SS=S;

R=rand(M,N);

G=R;

B=R;

C=cat(3,R,G,B);

fig=figure;

set(fig,'

DoubleBuffer'

mov=avifile('

example2.avi'

cc=imshow(C,[]);

Position'

[13355157194])

x1=(1:

3)+round(M/2);

y1=(1:

3)+round(N/3);

x2=(1:

3)+round(M/3);

y2=(1:

3)+round(N/2);

x3=(1:

3)+round(M/1.5);

y3=(1:

q=0;

qq=15/4;

whileq<

time;

SS=zeros(M,N);

fork=1:

15;

r=rand(M,N);

%���ɼ���r

K=zeros(M+2,N+2);

T=(S-k>

=0);

%����������

K(2:

end-1,2:

end-1)=T;

SS=K(1:

end-2,1:

end-2).*(r<

p

(1))+...

K(1:

end-2,2:

end-1).*(r<

p

(2)&

r>

=p

(1))+...

end-2,3:

end).*(r<

p(3)&

=p

(2))+...

K(2:

end-1,1:

p(4)&

=p(3))+...

end-1,3:

p(5)&

=p(4))+...

K(3:

end,1:

p(6)&

=p(5))+...

end,2:

p(7)&

=p(6))+...

end,3:

end).*(r>

=p(7))+SS;

end

S=SS;

%SS��������ɢ��ķֲ�

S(S>

15)=15;

S(x1,y1)=15;

S(x2,y2)=15;

S(x3,y3)=15;

%����Դ��ֵ

G=(S<

=7.5);

B=(S>

qq);

R=(S>

qq&

S<

C=double(cat(3,R,G,B));

set(cc,'

C);

q=q+1;

pause(0.2);

title(['

q='

num2str(q)]);

Nu(q)=sum(S(1:

F=getframe(gca);

mov=addframe(mov,F);

mov=close(mov);

figure;

plot(Nu)

file4:

��Ŀ:

�����ε�Ԫ���Զ����ϵĵ������˶�

ժҪ:

�������������ε�Ԫ���Զ�����ģ�ⵥ�����˶�,�㷨�ǻ���FHP����.Ԫ���Զ���ģ��������ǵ���ͼ

�ؼ���:

������,Ԫ���Զ���,FHP����

figure('

[1530997658],'

NumberTitle'

off'

name'

�����ε�Ԫ���Զ����ϵĵ������˶�'

%Author'

semail:

zjliu2001@

%Reference:

%U.Frisch,B.Hasslacher,Y.Pomeau,Lattice-gas

%automatafortheNavier-Stokesrquation,Phys.Rev.

%Lett.1986,56:

1505-1508

axissquare;

boxon;

set(gca,'

XColor'

r'

YColor'

[-0.010.110.7750.815]);

L=17.5*0.1/sqrt(3);

axis([0,L,0,1]);

holdon;

forp=0:

.1:

0.9;

plot([0,(1-p)/sqrt(3)],[p,1],'

k'

end

0.1/sqrt(3):

1;

plot([p,min(p+1/sqrt(3),17.5*0.1/sqrt(3))],[0,min(1,(L-p)*sqrt(3))],'

plot([0,p],[p*sqrt(3),0],'

9;

plot([L-[0.05+p/10]/sqrt(3),L],[1,1-[0.05+p/10]],'

0.05:

plot([0,L],[p,p],'

po=plot(0.8/sqrt(3),0.5,'

r.'

markersize'

24);

pz=0.8/sqrt(3)+0.5i;

%thepositionofreadpoint

A=pi/3*2;

%themovementdirectionofreadpoint

gc=gca;

a1=axes('

[0.7,0.5,0.25,0.3]);

holdon;

axis([0,1,0,1]);

plot([0.5+0.5i,(1+i)/2+0.4*exp(i*pi/3*2)]);

plot([0.5+0.5i,(1+i)/2+0.4*exp(i*pi/3)]);

plot([0.3,0.7],[0.5,0.5]);

text(0.2,0.8,'

Y'

fontsize'

14);

text(0.73,0.8,'

X'

text(0.2,0.4,'

Z'

axes(gc);

dt=0.1/sqrt(3);

k=0;

ses=['

whilek;

'

...

'

pz=pz+dt*exp(i*A);

ifimag(pz)>

0.99|imag(pz)<

0.01;

...

A=-A;

end;

ifreal(pz)>

0.99|real(pz)<

A=-A-pi;

set(po,'

XData'

real(pz),'

YData'

imag(pz));

pause(0.2);

];

po1=uicontrol(gcf,'

style'

push'

unit'

normalized'

position'

[0.74,0.87,0.1,0.08],...

string'

start'

18,'

callback'

[]);

set(po1,'

['

k=~k;

ifk==1;

'

stop'

elseset(po1,'

ses]);

file5:

%DLA

%%%%%��Դ���ܲ���վ

clc;

clear;

closeall;

S=ones(40,100);

%statematrix

S(end,:

)=0;

%initialsttae

Ss=zeros(size(S)+[1,0]);

%toplineisoriginofparticle

Ss(2:

end,:

)=S;

%showingmatrix

N=size(S,2);

II=imagesc(Ss);

axisequal;

colormap(gray)

whilesum(1-S(1,:

))<

0.5;

y=1;

x=round(rand*[N-1]+1);

%randomposition

D=0;

whileD<

%randomtravel

r=rand;

ifabs(x-1)<

0.1;

SL=1;

else

SL=S(y,x-1);

end

ifabs(x-N)<

SR=1;

SR=S(y,x+1);

ifSL+SR+S(y+1,x)<

2.5;

%checktheneighbor:

left,right,under

D=1;

S(y,x)=0;

%stopintheposition

ifr<

=1/3;

%travelrandomly

x=x-1;

elseifr<

=2/3;

x=x+1;

y=y+1;

Ss(2:

ifx<

0.5|x>

N+0.5;

%outoftherange

else

Ss(y,x)=0;

%toshowthemovingparticle

set(II,'

Ss);

%toshow

pause(0.1);

end

file6:

functionsands(N);

%ɰ�ѹ���

%�ο���Ŀ��

%����ϵͳ��Ԫ���Զ���ģ��

%����:

(Ӣ��)Ф���µ

�����ף��ѧ����

closeall

Doublebuffer'

D=ones(N);

D1=D;

[X,Y]=meshgrid(1:

N);

Z=2*X-Y;

p=fix(9.5*N/21);

D(Z>

p&

Z<

9+p)=0;

D(fix(end/2)+1:

)=1;

D=min(D,flipud(D).*D1);

D=min(D,fliplr(D).*D1);

D(end,fix(end/4.13):

end-fix(end/4.13))=0;

D(end-1,fix(end/4.12):

end-fix(end/4.12))=0;

D(end-2,fix(end/4.1):

end-fix(end/4.1))=0;

%imshow(D,[])

%����������װɰ��ƿ��

B=ones(N);

B(Z>

B(fix(end/2)+1:

B(:

fix(end/2)+1:

end)=1;

B=min(B,fliplr(B));

B(1:

3,:

%figure;

%imshow(B,[])

%mov=avifile('

example2900.avi'

kk=3800;

fork=1:

kk;

[B,Nu]=duisha(D,B);

Bk=min(D,B);

imshow(Bk,[])

Ha(k)=Nu;

%F=getframe(gca);

%mov=addframe(mov,F);

%mov=close(mov);

plot(Ha)

function[Y,Nu]=duisha(D,B);

Dq=10*(1-D);

Bg=1-B+Dq;

%�о�ɰ������

S=zeros(size(B));

S1=S;

S2=S;

S(2:

)=Bg(2:

)-Bg(1:

end-1,:

S1(S==-1)=1;

S2(1:

)=S1(2:

Bg(S1==1)=~Bg(S1==1);

Bg(S2==1)=~Bg(S2==1);

%�о�ɰ���㵹

clearS

clearS1

clearS2

S(1:

end-1)=Bg(1:

end-1)+Bg(2:

end-1)-Bg(2:

end-2);

S1(S==2)=1;

S2(2:

end-2)=S1(1:

end-1);

Bg(S1==1)=0;

Bg(S2==1)=1;

end);

end)=S1(1:

Y=(1-Bg).*D;

Nu=prod(size(find(Y==0)));

file7:

time=500;

S=zeros(M,N);

R=1-S;

G=S;

B=S;

x=round(M/2);

y=(1:

SS=zeros(M,N);

fork=1:

r=rand(M,N);

%���ɼ���r

K=zeros(M+2,N+2);

T=(S-k>

K(2:

SS=K(1:

K(1:

K(2:

K(3:

end

S=SS;

S(S>

S(x,y)=15;

G=(S<

=10);

B=(S>

5);

R=(S>

5&

C=double(cat(3,R,G,B));

set(cc,'

q=q+1;

pause(0.2);

title(['

Nu(q)=sum(S(1:

file8:

������Ϸ(CameofLife)��J.H.Conway��20����60���ĩ��Ƶ�һ�ֵ�����ļ������Ϸ(Garclner��M.��1970��1971)�������ִ���Χ����Ϸ��ijЩ�������������ƣ�Χ�����кڰ��������ӡ�������Ϸ�е�Ԫ����{"

��"

}����״̬{0��1};

Χ��������ǹ��򻮷

ֵ����񣬺

ڰ������ڿռ�ķֲ�����˫���������������ϷҲ�ǹ��򻮷

ֵ�����(Ԫ���ƹ�������ֲ��������ڡ�������Χ������ӷֲ��ڸ����������)������Ԫ���ľֲ��ռ乹��������������ֻ���������Ϊ�򵥡

��������������Ϸ�Ĺ��ɼ�����:

(1)Ԫ���ֲ��ڹ��򻮷

ֵ������ϣ�

(2)Ԫ������0��1����״̬��0����"

��l����"

��

(3)Ԫ�������ڵ�8��Ԫ��Ϊ�ھӡ���Moore�ھ���ʽ��

(4)һ��Ԫ�������������ڸ�ʱ�̱��������״̬����Χ�˸��ھӵ�״̬(ȷ�н���״̬�ĺ�)����:

���ڵ�ǰʱ�̣����һ��Ԫ��״̬Ϊ"

���Ұ˸�����Ԫ������������������״̬Ϊ"

��������--ʱ�̸�Ԫ����������Ϊ"

������"

ȥ��

���ڵ�ǰʱ�̡����һ��Ԫ��״̬Ϊ"

���Ұ˸�����Ԫ��������������Ϊ"

�����Ԫ������һʱ��"

����"

�����򱣳

�Ϊ"

�������Ĺ�����ȥ�ܼ򵥡

���������Ϸ�Ǿ��в�����̬ͼ���Ͷ�̬�ṹ������Ԫ���Զ���ģ�͡����ܲ����ḻ�ġ���Ȥ��ͼ����������Ϸ���Ż����ʼԪ��״ֵ̬�ķֲ��йأ���������ij�ʼ״̬�ֲ���������ɲ������㣬�е�ͼ����ܿ���ʧ�����е�ͼ����̶��������е��ܶ���ʼ�ظ������򼸸

�ͼ�����е����Ѷ��С��е��򱣳

�ͼ�������ƶ��������ı��󡭡

�����������������"

�����(��Glider)"

��ͼ����

matlab�������£

%���кڵ��ʾ����

%�׵��ʾ����״̬

functionGame_of_Life(n)

%������Ϸ

%Game_of_Life(100);

n=100;

B=round(rand(n+2));

Z=B(2:

H=imshow(Z,[]);

[241132560420])

xlabel('

Pleasepress"

space"

keyandstopthisprogram!

...

'

12,'

color'

title('

Gameoflife'

b'

s=get(gcf,'

currentkey'

ifstrcmp(s,'

space'

clc;

k=0;

A=sumfun(B);

X=zeros(n);

X(Z==1&

(A==2|A==3))=1;

X(Z==0&

A==3)=1;

B(2:

end-1)=X;

Z=X;

set(H,'

1-X);

pause(0.5);

figure(gcf);

functionS=sumfun(B);

%��Χ8��λ�õ

ĺ�

S=B(1:

end-1)+...

B(3:

B(2:

end-2)+...

end)+...

B(1:

file9:

���x([i-1,i,i+1],t)����[001]����[100]ʱ��x(i,t+1)�ŵ���1���������x(i,t+1)����0��

Ҳ����:

����001100����

��һ��110

functionsierpinski3_by_CA(n);

%sierpinski3_by_CA(256);

X=zeros(n);

X(1,round(n/2))=1;

round(n/2);

X(k+1,2:

end-1)=and(xor(X(k,1:

end-2),X(k,3:

end)),...

~X(k,2:

end-1));

pause(0.05);

nm=round(n/2);

nm;

X(nm+k,1:

end)=X(nm-k,1:

file10:

file11:

functionClumsychild(c1,m);

%ʵ��Ԫ���Թ̶��ĸ��������ڵ�4��Ԫ����ɢ

%Clumsychild(0.1,0.1);

zjliu2001@

N=100;

A=randperm(N^2);

S=zeros(N);

S(A(1:

3000))=3;

%30%��λ����״̬3

S(A(3001:

5000))=1;

%20%��λ����״̬1

S(A(5001:

6000))=2;

%10%��λ����״̬2

clearA;

[15942567427]);

imagesc([1:

4]'

YAxisLocation'

right'

[0.8,0.1,0.1,0.8])

[0.84,0.12,0.1,0.8])

xtick'

ytick'

[1:

4]);

yticklabel'

num2str([0:

3]'

));

axes('

[0.06,0.12,0.7,0.8]);

H=imagesc(S);

[15942485427]);

title(['

c1='

num2str(c1),'

m='

num2str(m)]);

whilek

S=evolvement(S,c1,m);

S);

functionS=evolvement(S,c1,m);

P=zeros(size(S));

Da=rand(size(S));

Da(Da>

1-c1)=1;

Da(Da<

1-c1)=0;

P(S==1|S==2)=1;

R=round(rand(size(S))+1);

P=P.*R.*Da;

V=round(rand(size(S))*3)+1;

V=V.*P;

%V���ٶȷ���:

%1---up

%2---down

%3---left

%4---right

V(1,V(1,1:

end)==1)=0;

V(end,V(end,1:

end)==2)=0;

V(V(1:

end,1)==3,1)=0;

end,end)==4,end)=0;

%�������

[x,y]=find(V==1);

DD=zeros(size(S));

DD(x-1,y)=P(x-1,y);

S(S==0|S==2&

DD==1)=1;

S(S==0&

DD==2)=2;

[x,y]=find(V==2);

DD(x+1,y)=P(x+1,y);

[x,y]=find(V==3);

DD(x,y-1)=P(x,y-1);

[x,y]=find(V==4);

DD(x,y+1)=P(x,y+1);

Dr=rand(size(S));

S(S<

3&

Dr<

m)=0;

file12:

ʵ��Ԫ���Թ̶��ĸ��������ڵ�4��Ԫ����ɢzz���⣬Ԫ���Զ���ģ��������ǵ���ͼԪ���Թ̶��ĸ��������ڵ�4��Ԫ����ɢzz���⣬Ԫ���Զ���ģ��������ǵ���ͼ

�ܲ�@2005-06-1608:

36

���������Ԫ���Զ���ģ�����£

����һ��100��100�ĸ��ӣ�ÿ

��Ԫ������4��״̬����0��1��2����3�������������0״̬��

����������Ϊ��������ǿհף��ҿ��Ծ�ס�ġ��������1״̬��������Ϊ�õ

�Ϊǿ����1��

ռ�У��������2״̬��������Ϊ�õ

�Ϊ������2��ռ�С���״̬3��������һ�����ƻ��˵ĵ�

�㣬���ܱ��κ�����ռ�С�

1���������״̬1������2������ô

�õ

�ĸ�����c1������c2�����ٶȲ��������

2������i�ĺ������ص������������ĸ�Ԫ�������������������1�ģ���ô

��������

ɢ�����Ծ�ס��Ԫ���ϣ�Ϊ�յ�Ԫ�������DZ�����2��ռ�е�Ԫ������״̬Ϊ0����2�����

������������2�ģ���ô

��ֻ����ɢ���հ��ҿ��Ծ�ס��Ԫ���С�����������ɢ������

����Ԫ����״̬Ϊ3���ģ���ô

����ʧ�ܡ�

3�����һ��Ԫ������1����2��״̬�����Ԫ������m�ĸ��������

Ҳ����˵��ǿ������c1���ٶȲ����������������������ط��͵����ڵ�Ԫ���У�ǿ����

1�Ŀ������ֵ��հ׵�Ԫ���У����߱�������2��ռ�ĵط���������2��c2���ٶȲ��������

���Ѻ����������������ڵ�Ԫ���У������ֵĺ��ֻ�����ֵ��հ׵�Ԫ���У�״̬Ϊ0����

������������ֵ��ٻ���Ԫ���У�״̬Ϊ3������ô

������ֲ��ɹ����������������⣬

����2��������˵�����嶼��һ���ܶ������������ʡ�

����Ԫ���ó

�ʼ״̬�����Ƕ���Ϊ��

��D��0.3����Ϣ�������ƻ���Ҳ����30���ĸ��ӣ�Ԫ��������Ϊ������ռ�죬�����ǵ�״̬

Ϊ3����ֵΪ3����������1�ı���Ϊ0.2������20���ĸ���Ϊ����1��ռ�죬״̬Ϊ1������2

�ı���Ϊ0.1������10���ĸ���Ϊ����2��ռ�죬״̬Ϊ2�����հ׵ĸ���Ϊ0.4������40����

���ӿɹ����־�ס������δ��ռ�죬��״̬Ϊ0��

file13:

�����ƶ������˱��ϵ�ʵ��

�ܲ�@2006-02-0713:

32

%�����ƶ������˱��ϵ�ʵ��

[0.1,0.15,0.56,0.7]);

N=50;

A=ones(N,N,3);

xn=round((N+1)/2);

yn=xn;

A(xn,yn,:

A(10:

13,10:

13,2:

3)=0;

A(40:

43,10:

13,40:

43,2:

43,40:

H=imshow(A);

p=[1,-1,i,-i];

ss=['

whilek==1;

t=round(3*rand)+1;

x=real(p(t));

y=imag(p(t));

xn=xn+x;

yn=yn+y;

ifxn<

1|xn>

N;

xn=mod(xn,N)+1;

ifyn<

1|yn>

yn=mod(xn,N)+1;

ifA(xn,yn,2)==0;

xn=xn-x;

yn=yn-y;

elseA(xn,yn,:

set(H,'

A);

[0.74,0.6,0.2,0.08],...

ss]);

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > IT认证

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1