资源简介
内含元胞自动机MATLAB实现的示例程序(可运行),供学习用

代码片段和文件信息
%Conway‘s life with GUI
clf
clear all
%=============================================
%build the GUI
%define the plot button
plotbutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Run‘ ...
‘fontsize‘12 ...
‘position‘[1004005020] ...
‘callback‘ ‘run=1;‘);
%define the stop button
erasebutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Stop‘ ...
‘fontsize‘12 ...
‘position‘[2004005020] ...
‘callback‘‘freeze=1;‘);
%define the Quit button
quitbutton=uicontrol(‘style‘‘pushbutton‘...
‘string‘‘Quit‘ ...
‘fontsize‘12 ...
‘position‘[3004005020] ...
‘callback‘‘stop=1;close;‘);
number = uicontrol(‘style‘‘text‘ ...
‘string‘‘1‘ ...
‘fontsize‘12 ...
‘position‘[204005020]);
%=============================================
%CA setup
n=128;
%initialize the arrays
z = zeros(nn);
cells = z;
sum = z;
%set a few cells to one
cells(n/2.25*n:.75*n) = 1;
cells(.25*n:.75*nn/2) = 1;
%cells(.5*n-1.5*n-1)=1;
%cells(.5*n-2.5*n-2)=1;
%cells(.5*n-3.5*n-3)=1;
cells = (rand(nn))<.5 ;
%how long for each case to stability or simple oscillators
%build an image and display it
imh = image(cat(3cellszz));
set(imh ‘erasemode‘ ‘none‘)
axis equal
axis tight
%index definition for cell update
x = 2:n-1;
y = 2:n-1;
%Main event loop
stop= 0; %wait for a quit button push
run = 0; %wait for a draw
freeze = 0; %wait for a freeze
while (stop==0)
if (run==1)
%nearest neighbor sum
sum(xy) = cells(xy-1) + cells(xy+1) + ...
cells(x-1 y) + cells(x+1y) + ...
cells(x-1y-1) + cells(x-1y+1) + ...
cells(3:ny-1) + cells(x+1y+1);
% The CA rule
cells = (sum==3) | (sum==2 & cells);
%draw the new image
set(imh ‘cdata‘ cat(3cellszz) )
%update the step number diaplay
stepnumber = 1 + str2num(get(number‘string‘));
set(number‘string‘num2str(stepnumber))
end
if (freeze==1)
run = 0;
freeze = 0;
end
drawnow %need this in the loop for controls to work
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-08-26 21:06 元胞自动机\
目录 0 2019-08-26 21:06 元胞自动机\示例-源程序\
文件 17 2018-06-30 21:37 元胞自动机\示例-源程序\README.txt
文件 2226 2018-06-30 18:31 元胞自动机\示例-源程序\calife.m
文件 1478 2019-08-26 21:06 元胞自动机\示例-源程序\cellular.m
文件 135 2018-06-30 21:37 元胞自动机\示例-源程序\clear_boundary.m
文件 126 2018-06-30 21:37 元胞自动机\示例-源程序\compute_output.m
文件 137 2018-06-30 21:37 元胞自动机\示例-源程序\compute_wait.m
文件 521 2018-06-30 21:37 元胞自动机\示例-源程序\create_entry.m
文件 939 2018-06-30 21:37 元胞自动机\示例-源程序\create_plaza.m
文件 803 2018-06-30 18:31 元胞自动机\示例-源程序\forest.m
文件 1215 2018-06-30 21:37 元胞自动机\示例-源程序\move_forward.m
文件 259 2018-06-30 21:37 元胞自动机\示例-源程序\new_cars.m
文件 1106 2018-06-30 21:37 元胞自动机\示例-源程序\switch_lanes(1).m
文件 1107 2018-06-30 21:37 元胞自动机\示例-源程序\switch_lanes.asv
文件 1106 2018-06-30 21:37 元胞自动机\示例-源程序\switch_lanes.m
相关资源
- 组合导航matlab程序
- 替代数据法的matlab程序
- 神经网络分类matlab程序
- matlab程序用Hopfield网络解决TSP
- 多用户检测MATLAB程序
- 实现2ask.4ask.2fsk.4fsk.qam16.qam8调制的m
- 曲线旋转得到曲面的MATLAB程序
- 主动轮廓模型算法matlab程序
- Lozi混沌系统相关分析的MATLAB程序
- 用蚁群算法求解TSP问题的matlab程序
- 分数阶chen混沌matlab程序
- 基于粒子群算法的非合作博弈的matl
- KF+EKF matlab程序实现
- 圆拟合matlab程序,以及圆心 半径的确
- stlwritematlab程序
- 层次分析法的matlab程序
- 泊松过程的模拟及检验 matlab程序
- 世上最牛的23个图像跟踪算法MATLAB程序
- matlab2007B数模乘公交看奥运_搜索法+
- 散点拟合平面的MATLAB程序
- 信号检测与估计-理论与应用答案及
- ROC曲线MATLAB程序
- dijkstra算法改进的matlab程序能求出两点
- EEMD的MATLAB程序
- 基于遗传算法的机器人路径规划matl
- 基于自适应压扩法降低OFDM系统的峰均
- Origin 9.0科技绘图与数据分析超级学习
- 求露点温度matlab程序
- 计算图像Spatial Frequence的Matlab程序SF
- 德州扑克获胜概率计算的MATLAB程序
评论
共有 条评论