在矩阵matlab中查找元素组

时间:2014-09-02 21:13:36

标签: matlab

我有一系列元素E = [1 2 3 4 5 10]和一对元素矩阵A

A=[ 1 2;
    2 3;
    3 1;
    4 1;
    4 3;
    5 1]

您可以将此矩阵读作

1 is similar (with a certain probability) to 2
2 is similar (with a certain probability) to 3
3 is similar (with a certain probability) to 1 etc...

我想知道给定矩阵A的数组E中有多少个不同的元素组 在这种情况下,我有

1 group = 1 2 3
2 group = 1 3 4
3 group = 1 5
4 group = 10

所以E

中有4个不同的元素组

注:

if 1 is similar to 2 (first row)
and if 5 is similar to 1 (sixth row)
5 is not similar to 2!!! (if it is not written anywhere)

所以1 2 5不属于同一组

另一方面

1 is similar to 2 (first row),
2 is similar to 3 (second row)
and  3 is similar to 1 (third row)

所以1 2 3属于同一组

0 个答案:

没有答案