Matrix manipulation depending on maximum and minimum values of existing matrix.

1 次查看(过去 30 天)
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

采纳的回答

Image Analyst
Image Analyst 2014-4-24
I'd think you'd extract each column, sort to get the sorting indexes, then put those back into the table. Something like (untested);
% Extract column 1
column1 = table1.BASAVARAJ;
% Sort column1
[sortedValue, sortIndexes] = sort(column1);
% Stuff back in
table1.BASAVARAJ = sortIndexes;
Repeat for the other columns.
  2 个评论
prashanth
prashanth 2014-4-25
First i have to sort diagonal elements.Next i have to sort remaining.One problem is zero should be remain same. It should not be altered.How it can be done?
prashanth
prashanth 2014-4-25
Please help me iam doing my last module of my project.My deadline of my project is very nearer.Please someone help me.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by