MATLAB: How to use matlab function to fill or label the previous or next column cells with respect to certain column of of a matrix with a number (3)

dilationMATLAB

As clear from figure, this is my M-matrix.
With respect to 2nd colum, in first colum, the 3rd row or 4th row i.e horizentally, i want to fill with 3 i.e. horizentally or diagonally.
similarly in 3rd column, i want to fill 3rd row or 4th rows same like above procedure.
% i want in each colum to have closing ie. startring 3 and then closing 3 i.e. the last one. Thanks for all coopeation. Warm regrads
question to ask.jpg

Best Answer

Try imdilate() -- it's a local max filter.
se = [0,0,0;1,1,1;1,1,1]
outputMatrix = imdilate(inputMatrix, se);