added conways, handouts
This commit is contained in:
12
conways/growth.m
Normal file
12
conways/growth.m
Normal file
@@ -0,0 +1,12 @@
|
||||
% growth function: given some matrix, determines whether a cell's neighbor
|
||||
% should die or live.
|
||||
% for any given entry u in matrix U:
|
||||
% u == 3 --> u_iter = 1
|
||||
% u > 3 OR u < 2 --> u_iter = -1
|
||||
% else u = 0
|
||||
function U_iter = growth(U)
|
||||
K = [1 1 1; 1 0 1; 1 1 1];
|
||||
|
||||
U_iter = conv2(U, K, 'same');
|
||||
U_iter = (U_iter == 3) - (U_iter > 3 | U_iter < 2);
|
||||
end
|
||||
Reference in New Issue
Block a user