matlab feature vector with the magnitude of the eigenvalues in descending order

 In fact, MATLAB built-in functions have diag () may be a diagonal matrix into a vector, a vector can also be transformed into a diagonal matrix. After completion of the conversion of vector reverse order, I saw some students simply write a bubble sort to do this, your data structure teacher must be very pleased. But no scratch in MATLAB, a direct call sort () function on the line - but here there is a more simple method, wrev () function can be a vector reverse order, fliplr () function can be approximately a matrix mirror-symmetrical , so if the want eigenvalues ​​in descending order, as long as such on the list:

% Obtained in descending order of the eigenvalue
[V, D] = EIG (A);
the lambda wrev = (diag (D));
V = fliplr (V);

example:

clear all;clc;close all;
A=[61.45,55.9,61.95,59,58.14,53.61,55.48,54.21,61.52,54.92];
B=[40.36,39.8,49.2,48,51.5,49.39,51.13,58.06,61,62.35];
C=[8.61,8.91,10.43,13.32,13.48,15.75,18.14,19.95,21.95,23.53];
D=[14.31,14.72,15.28,15.91,14.67,15,15.86,15.16,13.72,12.94];
E=[7.67,7.75,8.15,9.24,10.68,10.58,10.31,10,8.91,8.51];
q=[A',B',C',D',E'];
w=cov(q);
% 得到从大到小排列的特征值
[V, D] = eig(w);
lambda = wrev(diag(D));
V1 = fliplr(V)

Reprinted: https://blog.csdn.net/robertchenguangzhi/article/details/40747285

Scheduling Matlab matrix eigenvalue

Published 234 original articles · won praise 61 · views 120 000 +

Guess you like

Origin blog.csdn.net/weixin_42528089/article/details/104526827