How can I compare row by row to get rid if reciprocols and get corresponding indices

1 回表示 (過去 30 日間)
hello, I have a data matrix looks like below.
A=[4 5 0 0 0 10 0 15 0 0.19218
4 5 0 0 0 15 0 20 0 0.06548
4 5 0 0 0 20 0 25 0 0.02662
4 5 0 0 0 25 0 30 0 0.01446
4 5 0 0 0 30 0 35 0 0.00708
4 5 0 0 0 35 0 40 0 0.00487
4 15 0 10 0 20 0 25 0 0.31673
4 15 0 10 0 25 0 30 0 0.09447
4 15 0 10 0 30 0 35 0 0.03430
4 15 0 10 0 35 0 40 0 0.02008
4 15 0 10 0 40 0 45 0 0.01002
4 15 0 10 0 45 0 50 0 0.00502
4 15 0 10 0 50 0 5 0 0.33494
4 10 0 15 0 5 0 0 0 0.19150
4 20 0 15 0 25 0 30 0 0.43342
4 20 0 15 0 30 0 35 0 0.10293
4 20 0 15 0 35 0 40 0 0.04998
4 20 0 15 0 40 0 45 0 0.02261
4 20 0 15 0 45 0 50 0 0.01038
4 20 0 15 0 50 0 55 0 0.00523
4 20 0 15 0 55 0 10 0 0.54030
4 15 0 20 0 10 0 5 0 0.37795
4 15 0 20 0 5 0 0 0 0.06513
];
Basically,I want compare row by row based on column [ 2 4 6 8]. for example,first row column 2,4, 6,8 is 5,0,10,15. and the 14th row column 2,4,6,8 is 10,15,5,0. In this case, I need the index of the two rows since I only want one row. For a second example,please compare 2nd and 15th row,2nd row has 5,0,15,20 and 15th row has 15,20,5,0. This is just part of my data, I have many reciprocol measurements which is roughly the same as I showed above.If anyone knows how can I solve this problem,please let me know. I do not want change the order of my data. Thanks

採用された回答

Sean de Wolski
Sean de Wolski 2012 年 10 月 29 日
Look at using the various outputs from unique().
doc unique
  3 件のコメント
Sean de Wolski
Sean de Wolski 2012 年 10 月 29 日
So use the 'rows' flag on the subset that you need. I.e. extract the columns you want to count and then look at unique rows of this. If you could make your example smaller with the expected results we might be able to help more. The matrix you show us is huge and we don't know what you expect.
Show us an example with a 5x4 matric and the results from it.
Lei
Lei 2012 年 10 月 29 日
編集済み: Lei 2012 年 10 月 29 日
Hello Sean, Basically, I want compare this:
A=[ 5 0 10 15 0.021
5 0 15 20 0.011
10 15 5 0 0.022
15 20 5 0 0.009]
I need to compare first two columns of each row with the 3rd and 4th columns of all of the other rows.If the answer is true, I want the index of the two rows. So for this matrix, the comparison of row 1 and row 3 is true, same as row 2 and row 4,of coure, I need the index for both rows. But the other combinations, the comparisons are wrong.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by