I think you may be able to utilize the filter2 function for this purpose. For example
A = [1 2 3 4;5 6 7 8;9 10 11 12;13 14 15 16]
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
H = [0 1 0;1 0 1;0 1 0]
Af = filter2(H,A,'valid')
You will still need to apply your scaling with dx and dy but I think this should get you close.
Note the filter matrix
Tells it to compute the filtered element as the sum of the neighbors to the left and right and above and below, which I think is what you want. The 'valid' computes only interior points, as for example A(m-1,2) is not defined for m = 1. Actually they zero pad the edges and then compute the whole thing if you want that.
I realize this isn't exactly what you asked for, you wanted to vectorize it yourself. I'm not sure how you would do this without the double loop, maybe someone else has an idea, but in anycase I would assume that this built in MATLAB function is efficient, and keeps your code clean of complicated double loops (maybe they are in the built in function but you don't have to see them anyhow)