# MATLAB: How to change non zero value into 0

matrixmatrix arraymatrix manipulation

I want to manipulate n*n matrix such the last 10 non-zeros value in every column of matrix and change them into zero.Matrix is in the form of binary[0,1].

m = 10;B = cumsum(A);out = A.*(B(end,:) - m >= B);