If the NaNs represent missing data that should be assumed to vary smoothly with the surrounding data, then you would use the known data to do interpolation. Look in the file exchange for inpaint_nans .
If the NaNs represent "data at this location is invalid and should not be considered" (for example, land that is above water), then there is not a lot you can do with contouring. In that situation, perhaps you would
contour( kron(YourMatrix, ones(2,2)) )
the kron turns every location into a 2 x 2 block to give contour a chance to draw something -- but that does mess up your coordinate system.