新手请教Demo里的Game of Life
最近在研究元胞自动机,对MATLAB一知半解。遇到个问题,下段中的N E S W 是方向向量(方括号里的是我改过的,和原来的不一样,忘了原来的是什么的了),可是不太理解这个方向向量是什么意思?有没有同志可以解释一下?并把正确的内容贴出来!我感激不尽!% Whether cells stay alive, die, or generate new cells depends
% upon how many of their eight possible neighbors are alive.
% Here we generate index vectors for four of the eight neighbors.
% We use periodic (torus) boundary conditions at the edges of the universe.
n = ; e = ;
s = ; w = ;
while get(axHndl,'UserData')==play,
% How many of eight neighbors are alive.
N = X(n,:) + X(s,:) + X(:,e) + X(:,w) + ...
X(n,e) + X(n,w) + X(s,e) + X(s,w);
刚才找了个原始的LIFE.M,里面是这样的
n = ; e = ;
s = ; w = ;
为什么E和S, N和W是一样的呢?
[ 本帖最后由 ChaChing 于 2010-6-25 21:52 编辑 ]
页:
[1]