Change type of matrix