function to add a new matrix