I have few matrix. They are in few subgroups (I have vector which shows these subgroups - for example matrix 1 and 2 are in group A, matrix 3 in group B, matrix 4,5,6 in gro