Threshold the matrix with vector
Show older comments
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.
Accepted Answer
More Answers (1)
Wayne King
on 8 Oct 2012
Edited: Wayne King
on 8 Oct 2012
A = randn(5,3);
n = [0.5 0.8 0.2];
thresh = bsxfun(@gt,A,n);
B = A.*thresh;
B contains nonzero elements only where elements in A exceed the thresholds in the vector n.
2 Comments
Aravin
on 8 Oct 2012
Wayne King
on 8 Oct 2012
thresh is the 0 1 matrix just as I describe above
Categories
Find more on Image Thresholding in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!