Create a relation matrix from a sequence (Matlab)

后端 未结 2 731
逝去的感伤
逝去的感伤 2021-01-17 04:02

I have a sequence S :

  S= \'ABCD\' % which means A

I want to convert S into a matrix M[i,j] which have to satisfy those con

2条回答
  •  北海茫月
    2021-01-17 04:53

    Here's another similar approach:

    n = 4;
    M = tril(rand(n)*0.5, -1);
    P = triu(1-M.', 1);
    M = M + P + eye(n)*0.5;
    

    Result:

    M =
    
       0.500000   0.987433   0.711005   0.944642
       0.012567   0.500000   0.782633   0.902365
       0.288995   0.217367   0.500000   0.783708
       0.055358   0.097635   0.216292   0.500000
    

提交回复
热议问题