MATLAB: Center of matrix value

centerMATLABmatrix

How can i find the center value of a matrix NxN, where N is odd number. After that, how can i change that number for another number

Best Answer

a=(size(yourMatrix)+1)/2;
yourMatrix(a(1),a(2))=newNumber;