Simply replace completely missing rows or cols with zeroes.
tempFixNas(mat)
mat
a matrix
The original matrix with completely missing rows/cols filled with zeroes.
Henning Redestig