MATLAB: Removing values of an array greater then threshold value

arrayMATLAB

Hello,
I have an array of size 500×1 and I want to make the values lesser than threshold value to zero while copying the same values of array which are less than the threshold. can I know how to do this.
thanks.

Best Answer

newmatrix = max(oldmatrix, 0);
The above would replace all negative values with 0.
newmatrix = oldmatrix;
newmatrix(oldmatrix < threshold) = 0;