How can I create unique rows in a matrix?
4 次查看(过去 30 天)
显示 更早的评论
I write a program and the output is like:
C =
0 0 0
3 6 6
4 5 6
4 6 5
5 4 6
5 5 5
5 6 4
6 3 6
6 4 5
6 5 4
6 6 3
Now I want to short rows and then delete unique rows. like there will be anly 4 5 6 not both 4 5 6 and 4 6 5. I think you get it. Thank you
1 个评论
Sudhakar Shinde
2020-10-27
编辑:Sudhakar Shinde
2020-10-27
Row with value- 4 5 6 and 4 6 5 are not duplicated these are two separate unique rows.
Example: A=[1 2 3; 3 4 5;1 2 3]; here 1st and 3rd row is duplicated. Now you can use 'unique' function to remove duplicate row.
[C,ia,ic] = unique(A,'rows');
uA = A(ia,:); %unigue array
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!