MATLAB: Replacing value in satellite image.

image analysisImage Processing Toolboxnan

Dear,
I have a Satellite image 10980×10980. Some value in this image are 9.3886e+36. I want to replace these pixel with value NaN to compute mean of this Image.
I tried to use img(img==9.3886e+36)=NaN but somehow it is not working at all. I try this with a small matrix 2×8 then it is work but with my image it is not replace anything at all. Can anyone help me to solve this?
Best regards,

Best Answer

Use ismembertol():
badPixels = ismembertol(img, 9.3886e+36, 1e36);
img(badPixels) = nan;