From: Priom Rahman on
Could someone tell me how to search for all the zero's in a martix and then replace it wirh NaN ?

say:
x = [1 1 1 0; 1 1 0 0; 0 0 0 0; 1 1 0 1; 0 0 1 1]

x =

1 1 1 0
1 1 0 0
0 0 0 0
1 1 0 1
0 0 1 1

I can find the 0 using

find(x == 0)

ans =

3
5
8
10
12
13
14
16
17
18

But how do I replace these values ?

I'm sorry if similar questions have been answered, but I could only find examples of replacing NaNs with numbers or integers.
From: ImageAnalyst on
x(x==0)=nan
From: Walter Roberson on
ImageAnalyst wrote:
> x(x==0)=nan

x(~x)=nan; % :p
From: Priom Rahman on
Brilliant thanks !!!!!!