I haven't had much experience with Matlab and want to construct the "Game of Life" but I'm having trouble getting started. I want to write a function which gives the position of a cell or an empty place and gives the number of living neighbors to that cell. I've tried to look around on the Internet to find something that might help me but everything that I find seems to be too advanced. I want a function like:
function neighbors = numneighbors(M,i,j)
If I for example make M = [ 0 1 0 1 1 1 ; 0 1 0 1 0 1 ; 1 1 0 1 0 0 ] (or is there some way of constructing a random matrix of ones and zeros?)
How could I write the function?
All help is appreciated!