It would be best to remove the nan's from the array before you display it. And you forgot to say what line(s) of code you are using to display it (like fprintf or whatever).
To remove nans from an vector:
vec(isnan(vec)) = [];
vec will now be shorter if there were nans in it.
Unfortunately you can't remove nan's from a matrix because all rows and columns must be the same size -- you can't have "ragged" edges. The best you can do it to replace them with something, like 0 or -1 or whatever.
yourMatrix(isnan(yourMatrix)) = 0;