From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Neighbor Indexing
Date: Sat, 27 Nov 2010 00:24:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 7
Message-ID: <icpj34$242$>
References: <icpe5m$llt$> <>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1290817444 2178 (27 Nov 2010 00:24:04 GMT)
NNTP-Posting-Date: Sat, 27 Nov 2010 00:24:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2632069
Xref: comp.soft-sys.matlab:690359

Thank you for your prompt response, ImageAnalyst! I'm talking about an MxN grid of zeros and ones. If the majority of the 9 cells is 1, the updated cell becomes 0. If the majority of the 9 cells is 0, the updated cell becomes 1. My plan is to sum the states (0 or 1) of the 9 cells and if the sum is greater than or equal to 5, the majority is clearly 1 and the state will change to 0, etc. I understand how to create the random grid of zeros and ones and pick the random cell in the grid. What I am still confused about is how to incorporate the wrap around command within one loop. So far, I have accounted for the 9 cells when the chosen cell's neighbors are within the bounds:

sum(m, n) = [grid(m, n) + grid(m-1, n) + grid(m-1, n-1) + grid(m, n-1)+... +grid(m+1, n-1) + grid(m+1, n) + grid(m+1, n+1) + grid(m, n+1) + grid(m-1, n+1)]

When you say width and height is that the number of rows and number of columns in the grid?

Thank you again! So much!