Search code examples
matlabmatrixreplacefindsparse-matrix

Find indexes of arrayes of values in matrix and replace them with new value


I have a huge sparse matrix for ex A with n*n size , I want to find indexes of an array B (1*m size) of some values from the huge matrix and replace this values with one value such as x ? I don't want to use loop, how is it possible?

Thanks


Solution

  • Check this out:

    A(find(ismember(A,b))) = NaN
    

    P.S. : NaN is just as an example, you can tune the value, of course.