MATLAB: How to ignore NaN values in pcolor function

nanpcolor

I have three data lati, long, CaCO3. The size of each data is 180×1, 180×1, 180×180. lati and long don't have NaN values but CaCO3 have.
A part of CaCO3 matrix is
CaCO3 =
86.4195 88.6516 87.6645 NaN NaN
90.9402 89.1650 89.9154 NaN NaN
87.4232 94.4415 87.3036 91.3506 90.5179
NaN NaN NaN NaN NaN
NaN NaN NaN NaN NaN
NaN 91.5944 NaN NaN NaN
NaN 88.8381 87.1006 NaN NaN ……
NaN 89.5835 NaN NaN NaN
NaN 89.5548 NaN NaN NaN
87.2730 95.8932 87.5370 91.7358 91.7450
87.9113 96.3841 88.3516 89.7063 90.6103
89.8246 92.2127 90.4637 91.2455 92.1979
90.9599 93.2109 90.6547 97.5123 97.5610
When I used pcolor(long,lati.CaCO3), the result was a picture below. I think black lines represent because of NaN values, so how to ignore NaN values?

Best Answer

I don't think the black lines are because of the NaNs. Its coming from the default shading method, which is faceted. Try "shading flat" or "shading interp".
https://www.mathworks.com/help/matlab/ref/shading.html