Ordinarily I'd do this:
smoothed_m = conv2(m, ones(3)/9, 'same')
but modified to fix any edge effects:
numerator = conv2(m, ones(3), 'same')
denom = conv2(ones(size(m)), ones(3), 'same')
smoothed_m2 = numerator ./ denom
but it doesn't give you the same output values. However I'm not sure how you got those values. For example, let's take the middle value, which is totally not affected by edge effects. You say it's 5.25468 however in MATLAB:
m9 = [...
5.91996 0.659594 5.77286
8.38353 3.33698 9.03057
7.64424 0.474168 5.77164]
averageValue = mean2(m9)
which doesn't match your number. You'll have to define boxcar.