How to remove the swap vectors from a matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
BALAKRISHNA ADHIKARI
2020 年 10 月 5 日
コメント済み: BALAKRISHNA ADHIKARI
2020 年 10 月 5 日
Hello all,
I am facing few problem in MATLAB code and hoping to get solution from here. I am having a matrix of (30,2). As following
1 5
2 3
2 5
2 24
3 2
3 25
3 44
4 9
5 2
5 1
5 6
6 5
6 7
6 9
7 6
7 25
7 28
8 13
9 6
9 4
9 10
10 9
10 11
10 13
11 10
11 28
11 32
12 17
13 10
13 8
It can be seen that it has [2 3] in second row and [3 2] in fifth row andsimilarly few more rows are there. So, my problem is to remove the swaped row from the original and make another matrix. That means [2 3] will remain in the original matrix and [3 2] will goes to a new matrix. Similarly for other elements. Please help to get the code.
Best Regards
0 件のコメント
採用された回答
その他の回答 (1 件)
madhan ravi
2020 年 10 月 5 日
[Original_matrix, c, ~] = unique(sort(matrix, 2), 'rows');
New_matrix = matrix(setdiff(1:size(matrix, 1), c), :)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!