第一个矩阵表1包含5个名称的标准化值。我需要对此矩阵执行一些操作,我必须获得第二个矩阵,如表2所示。
table2的对角线元素应该通过给每个值赋予等级(序数值)来获得。这意味着最高元素被赋予第5等级,而第二高等等被给予第4等等,等等。
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
答案 0 :(得分:0)
试试这个:
da = diag(A); % A is your first matrix
[sda, I] = sort(da);;
for i = 1:length(da)
B(I(i)) = i;
end
B = diag(B) % B is your second matrix
答案 1 :(得分:0)
[~, ii] = sort(diag(table1));
[~, jj] = sort(ii);
table2 = diag(jj);