|
"Camille Couzi" <camillecouzi@yahoo.fr> wrote in message <j1tekl$ch5$1@newscl01ah.mathworks.com>...
> Hi matlabers!
> I am working with a huge matrix of data (10.000*100). In this matrix there are some values, let say =999 that I want to replace by NaN.
> When I usually wok with not so big matrices, I use find function:
> [row,col]=find(A==999);
> A(row,col)=NaN;
>
> but ins this case, as I have A HUGE matrix it last a loooooooong time to search for values with 'find' and more time to replace one by one the values in A.
>
> is there a faster way to do this calculation? perhaps using a mask?
>
> Any idea will be very welcomed. Thanks in advance!!!
>
> camille.
That is not so huge, unless you have a typo in the size.
Your code takes about 0.26 seconds on my laptop if there are about 10000 instances of 999 in the matrix. But your code replaces all the combinations of the index vectors, not only the 999s, which is probably what you want.
A(A==999) = nan;
takes about 0.0066 seconds with the same matrix and this will only replace the 999s.
hth
|