I have a matrix of 1's and 0's and I would like to combine any column that repeats itself in the matrix – e.g if a is the matrix below I want b be the combination of any columns that are the same so b would be as shown – a new matrix with a combined repeated columns added togtehr and none repated ones left the same.

`a = [1 1 1 0;1 0 0 0;0 0 0 1;1 1 1 0; 0 0 0 1]b = [2 2 2 0; 1 0 0 0; 0 0 0 2];`

The matrix I am actually dealing with is very large this is just a simplified version.

## Best Answer