matrix and threshold