How to retrieve unique columns in a matrix ?
42 次查看(过去 30 天)
显示 更早的评论
I would like to retrieve all the unique columns in a matrix..
If my matrix =
1 -1 1 1
1 1 1 1
2 1 1 1
UniqueColumns =
1 -1 1
1 1 1
2 1 1
Thank you before hand.
0 个评论
采纳的回答
Stephen23
2022-3-10
编辑:Stephen23
2022-3-10
A = [1,-1,1,1;1,1,1,1;2,1,1,1];
B = unique(A.','rows','stable').'
2 个评论
Laxmikant Sharma
2023-1-24
编辑:Laxmikant Sharma
2023-1-24
What if you want the indeces too?
[B idx] = unique(A.', 'rows', 'stable').'
Not working!!!
Stephen23
2023-1-25
"What if you want the indeces too?"
A = [1,-1,1,1;1,1,1,1;2,1,1,1];
[B,idx] = unique(A.','rows','stable');
B = B.'
idx
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!