I seem to have found a solution that does the job by determining multiplication factors prior to the calculations, i.e.;
new(is,js) = old(is,js) + notNaN(is,js).*(A0.*old(is,js) + A1.*old(is+1,js) + A2.*old(is-1,js) + A3.*old(is,js+1) + A4.*old(is,js-1))/4;
For instance, if my notNaN matrix is
0 0 0 0 0 0 0
0 0 0 1 1 1 0
0 0 1 1 0 1 0
0 0 1 1 0 1 0
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 0 0 0 0
I would get A1 to be
0 1 1 1 0
1 1 0 1 0
1 1 0 1 0
1 1 1 1 0
1 1 1 0 0
Which is equal to notNaN(is+1,js).
Consequently, that would mean
A1 = notNaN(is+1,js);
A2 = notNaN(is-1,js);
A3 = notNaN(is,js+1);
A4 = notNaN(is,js-1);
A0 = 4 - (A1+A2+A3+A4);
I could even eliminate the multiplication with notNaN(is,js) by performing that multiplication up front as well.