How can I delete the repeated values and keep just a row of each one?
1 view (last 30 days)
Show older comments
I have this matrix
[3 11 43;
3 17 41;
3 41 17;
3 43 11;
11 3 43;
11 43 3;
17 3 41;
17 41 3;
41 3 17;
41 17 3;
43 3 11;
43 11 3 ]
The result should be something like this [ 3 11 43; 3 17 41 ]
OBS. I tried unique() and it didn't work as I want.
0 Comments
Accepted Answer
Geoff Hayes
on 18 Feb 2019
DS - you could try
unique(sort(A,2), 'rows')
where A is the matrix that you have defined above. This could be inefficient though especially as your A gets larger. With this code, we sort all the columns for each row of A and then calll unique with rows so that each row is treated as a "single entity". See unique values in array for details.
0 Comments
More Answers (1)
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!