clean matrix