Matlab Matrix: Eliminating Duplicate Entries
1 回表示 (過去 30 日間)
古いコメントを表示
Hello, all, thanks for reading this post.
I have a problem with a point coordinate matrix I create. I output the matrix correctly, but one of the bugs in the program I inherited is every point after point 1 is duplicated. I looks something like:
0 0 0
0 0 3.0000
0 0 3.0000
0 1.4225 4.8659
0 1.4225 4.8659
0 -1.4269 4.8520
0 -1.4269 4.8520
1.1125 2.3073 6.0264
1.1125 2.3073 6.0264
-1.1160 2.3007 6.0177
-1.1160 2.3007 6.0177
1.1086 -2.3144 6.0039
1.1086 -2.3144 6.0039
-1.1120 -2.3078 5.9953
-1.1120 -2.3078 5.9953
for 8 coordinates (and 7 connections, as this is a binary tree).
Is there a way to output a new point coordinate matrix where I have 8 rows, and no duplicate points?
Thanks
Edit: unique(A,'rows') will work in my case (because the point coordinates are exactly the same), but when I use it it outputs the coordinates in alpha-numeric order. Is there a way to output the coordinates in their original order, minus the duplicates?
0 件のコメント
採用された回答
Fangjun Jiang
2011 年 11 月 17 日
unique(A,'rows')
6 件のコメント
Walter Roberson
2011 年 11 月 17 日
Using the indexing I suggested in my answer would deal with these issues much more readily...
その他の回答 (1 件)
Walter Roberson
2011 年 11 月 17 日
A(1:2:end,:)
This does not have the problem with comparing nearly equal quantities, but it does assume that the second row of each pair is acceptable
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!