If I have an array of size NxN,called X, and I count through it using an (i,j) for loop like this
for i = 1:N for j = 1:N
and im looking for a value in it like this
if(X(i,j) == 1)
I want to start where I find a 1 and change the diagonal lines around it to an 8. So far ive tried code similar to this and many things like it but it doesnt seem to work how I envision it
for i = 1:N for j = 1:N if(X(i,j) == 1) X(i+1,j+1) = 8; X(i-1,j-1) = 8; X(i+1,j-1) = 8; X(i-1,j+1) = 8; end endend
I want the outcome to be something like
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
this turns into this
8 0 0 0 8
0 8 0 8 0
0 0 1 0 0
0 8 0 8 0
8 0 0 0 8
Best Answer