New set function for matrices