MATLAB: Threshold the matrix with vector

MATLABmatrix and vector operationmatrix operatointhresholdthreshold with different dimension

Let say I have a matrix M with m x n dimensions. I want to threshold each column by different threshold. let say N contains the threshold for each column, therefore the dimension of N is n x 1 or 1 x n.
how can I do this by single command.

Best Answer

One possible way is ..
lets us assume that N is 1 x n vector
N = repmat(N,size(M,1),1);
M_binary = M > N;
or
M_binary = M < N;