How do I replace 0 with NaN in an 3D array?

9 vues (au cours des 30 derniers jours)
Lequette Kevin
Lequette Kevin le 28 Jan 2019
Hello,
I'm novice with matlab and I am looking for analyze a 3D object. However, the zero in my 3D array represent nothing in reality. So I would like replace them by NaN on each z before to perform more analysis of my object.
When I use:
img(img==0) = NaN
it does not work.
Have you another idea ?
Thanks :)

Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 28 Jan 2019
Maybe those values are not strictly zero. Try this example
a=zeros(2,2,2)
a(a==0)=nan

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by