Deleting similar rows in Matrices contained in cell
1 view (last 30 days)
Show older comments
If I have a set of [ 'a' 'b' 'c' 'd'],and I want different and non repetitive combinations of 2, I get matrix A. In matrix B I store the elements which are not present in Matrix A which I find using setdiff. Now, I want to divide these four elements 'a', 'b' 'c' 'd' into sets of two and that should be non repetitive. But, in the case below: ad cd is repeating as it is similar to cd ab, similarly, ac bd is same as bd ac.
I have two matrices in a cell: A = [ ab; ac; ad; bc; bd; cd ] and B = [cd; bd; bc; ad; ac; ab ]; So, is there any function in MATLAB which can help me eliminate repetitive partition cases? I looked into unique function but that did not help.
0 Comments
Answers (1)
Kye Taylor
on 31 May 2012
If I understand your objective, try the following
arrayOfElements = ['a','b','c','d']; % your initial array
indicesOfUniquePairs = nchoosek(1:length(arrayOfElements),2);
arrayOfUniquePairs = arrayOfElements(indicesOfUniquePairs);
It's a beautiful thing.
See Also
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!