Thank you very much for your kindly reply. Your method can work for the example I posted. However, it still can't work for the final matrix I need to be simplified, could you please help me to take a look at it?