Matlab code for Sorting diagonal elements of matrix and index of sorted elements is filled into new matrix as shown below?

2 views (last 30 days)
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 highest is given 4th 3rd and so on.
OPERATION: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)
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 0 0 0 0
MANOJ 0 1 0 0 0
NATESH 0 0 4 0 0
VIJAY 0 0 0 2 0
GOWDA 0 0 0 0 3

Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!