Check if matrix changed