In the job need to find the eigenvalues and eigenvectors of a matrix, of course, the students will use the MATLAB built-in functions [V, D] = Eig (A), so that the diagonal matrix D is a small-to-large arrangement of the characteristics of the value. Some students want to be able to separate this diagonal element into a row vector or column vector, but also hope that the characteristics of the value from large to small arrangement, in order to achieve this goal, we have used a variety of methods. In fact, MATLAB built-in functions have diag () can be a diagonal matrix into a vector, you can also convert a vector into a diagonal matrix. After the conversion of the vector in reverse order, I see a classmate obstinately wrote a bubble sort to complete this work, your data structure the teacher must be very gratified. But in MATLAB do not have to start from scratch, directly call the sort () function on the line ~ But here there are more simple methods, Wrev () function can be a vector in reverse order, FLIPLR () function can be a matrix left and right mirror symmetry, so if you want to get from large to small arrangement of eigenvalues, As long as this is OK:
% get eigenvalues from large to small arranged
[V, D] = Eig (A);
Lambda = Wrev (diag (D));
v = FLIPLR (v);
The eigenvalues and eigenvectors are all lined up.