Path: news.mathworks.com!not-for-mail 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$1@fred.mathworks.com> References: <icpe5m$llt$1@fred.mathworks.com> <ccd6261b-2090-447d-af5a-e90f2a26af77@o4g2000yqd.googlegroups.com> Reply-To: <HIDDEN> NNTP-Posting-Host: webapp-03-blr.mathworks.com Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: fred.mathworks.com 1290817444 2178 172.30.248.38 (27 Nov 2010 00:24:04 GMT) X-Complaints-To: news@mathworks.com NNTP-Posting-Date: Sat, 27 Nov 2010 00:24:04 +0000 (UTC) X-Newsreader: MATLAB Central Newsreader 2632069 Xref: news.mathworks.com 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!