用Matlab实现元胞自动机(网上收集、转载)
(2013-07-30 20:29:06)
标签:
it |
分类: Matlab |
file:life.m
%%
初始化
m = 50;
X = zeros(m,m);
X(25,25) = 1;
n = [m
1:m-1];
%% 演化
file 2:
function
sierpinski(n);
% 使用元胞自动机生成sierpinski直角垫片
% Example:
%
% %算法见:孙博文,《分形算法与程序设计:用Visual C++实现》
if nargin==0;
end
X=on
X(1,n-1)=0;
H=imshow(X,[]);
set(gcf,'doublebuffer','on');
k=1;
while k
end
file
3:
function CA_sim_cloud;
% 使用元胞自动机模拟地球卫星的云图
%
% reference:
% Piazza, E.; Cuccoli, F.;
% Cellular Automata Simulation of Clouds in Satellite
Images,
% Geoscience and Remote Sensing Symposium, 2001. IGARSS
'01.
% IEEE 2001 International Volume 4,
% 1722 - 1724 vol.4 Digital Object Identifier
10.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','on');
mov = avifile('example2.avi');
cc=imshow(C,[]);
set(gcf,'Position',[13 355 157 194])
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:3)+round(N/2);
q=0;
qq=15/4;
while q
=p(1))+...
=p(2))+...
=p(3))+...
=p(4))+...
=p(5))+...
=p(6))+...
end
mov = close(mov);
figure;
plot(Nu)
file
4:
题目: 六边形的元胞自动机上的单粒子运动
摘要: 本程序在六边形的元胞自动机上模拟单粒子运动,算法是基于FHP规则.
关键词: 六边形, 元胞自动机, FHP规则
figure('Position',[15 30 997
658],'NumberTitle','off');
set(gcf,'name','
% Author's email:
% Reference:
% U. Frisch, B. Hasslacher, Y. Pomeau, Lattice-gas
% automata for the Navier-Stokes rquation, Phys.
Rev.
% Lett. 1986,56: 1505-1508
set(gcf,'DoubleBuffer','on');
axis square;box on;
set(gca,'XColor','r','YColor','r');
set(gca,'Position',[-0.01 0.11 0.775 0.815]);
L=17.5*0.1/sqrt(3);
axis([0,L,0,1]); hold on;
for p=0:.1:0.9;
end
for p=0:0.1/sqrt(3):1;
end
for p=0:0.1/sqrt(3):1;
end
for p=0:9;
end
for p=0:0.05:1;
end
po=plot(0.8/sqrt(3),0.5,'r.','markersize',24);
pz=0.8/sqrt(3)+0.5i; % the position of read point
A=pi/3*2;
gc=gca;
a1=axes('Position',[0.7,0.5,0.25,0.3]);
axis square;hold on;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','fontsize',14);
text(0.2,0.4,'Z','fontsize',14);
axes(gc);
dt=0.1/sqrt(3); k=0;
ses=['while k;',...
po1=uicontrol(gcf,'style','push',...
set(po1,'callback',['k=~k;if k==1;',...
file
5:
% DLA
%%%%%来源:萝卜驿站
clc;clear;close all;
S=on
S(end,:)=0; % initial sttae
Ss=zeros(size(S)+[1,0]); % top line is origin of particle
Ss(2:end,:)=S; % showing matrix
N=size(S,2);
II=imagesc(Ss);axis equal;colormap(gray)
set(gcf,'DoubleBuffer','on');
while sum(1-S(1,:))<0.5;