So basically I have a 3 x 3 matrix of 1s and 0s, and I want to create another 3×3 matrix which has the sum of the adjacent (including diagonal) values for each element that is 0, and display 5 for each element that is 1.

For example, given the matrix

I =

` 0 0 1 1 0 1 0 1 0 I'd want to create the sum matrix that looks like this:`

C =

` 1 3 5 5 4 5 2 5 2`

## Best Answer