Changed function name as category_mat() and added a function to calculate weight cutoff.