MATLAB: Matrix manipulation, filtering

matrix manipulation

Given a large matrix containing values in range [0,1].
Is it possible to change (as in, set to fixed value, add value, subtract value ect.) elements above a certain threshold, without the use of loops? And without changing the rest of the matrix.

Best Answer

Of course - use logical indexing:
A = rand(5);
A(A>0.5) = 10; %set all values in a greater than 0.5 to 10