You likely want to use the imfilter function exactly as in this example, but swapping out the 5-by-5 example filter with a 7-by-7 of your choice.
If you look at the options available for imfilter ( see documentation ), you'll see there's a couple things you can configure for boundaries.
Sebastian