Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
521 views
in Technique[技术] by (71.8m points)

for loop - Sorting matrix diagonal wise and indexes are given as rank using matlab

This first matrix table1 contains normalized values for 5 names.I need to perform some operations on this matrix and I have to obtain second matrix as shown in table2.

Diagonal elements of table2 should obtained by giving rank(ordinal value) to each value.That means highest element is given 5th rank and next 4th 3rd and so on.

Remaining elements of table obtained by giving rank to each value starting from 4 because only 4 elements remaining. Because already we are given rank to diagonal elements.Zero should be kept as it is.Suppose take table1 as A matrix and table2 as B matrix.

OPERATION1:For diagonal elements

   B(1,1)=5(first largest element)
   B(2,2)=1(5th largest element)
   B(3,3)=4(4th largest element)
   B(4,4)=2(2nd largest element)
   B(5,5)=3(3rd largest element)

OPERATION2:For remaining elements

      B(1,2)=3(2nd largest element)
      B(1,3)=4(1st  largest element)
      B(1,4)=1(4th largest element)
      B(1,5)=2(3rd largest element)

And so on..

        Table1:
                                  BASAVARAJ   MANOJ      NATESH       VIJAY    GOWDA

           BASAVARAJ            1.0000    0.2727      0.3182     0.0455    0.2727

               MANOJ            0.2727   0.2727         0            0         0

              NATESH            0.3182     0          0.4545     0.1818        0

               VIJAY            0.0455     0          0.1818     0.2727     0.0909

               GOWDA            0.2727     0              0     0.0909    0.3636




   Table2:




                             BASAVARAJ    MANOJ      NATESH    VIJAY  GOWDA



  BASAVARAJ                      5         3       4        1       2
     MANOJ                       4         1       0        0       0
     NATESH                      4         0       4        3       0
     VIJAY                       2         0       4        2       3
     GOWDA                       4         0       0        3       3
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...