MATLAB Answers

0

Get in Order respond when using "eig" command

Asked by Maryam on 17 Aug 2018
Latest activity Answered by Christine Tobler on 17 Aug 2018
I am trying to find generalized eigenvalues and eigenvectors of a 12 by 12 system of equations. It is a structural dynamic problem: (K - M*phi)*V = 0 or K*V = M*phi*V
In this case, "phi" is the eigenvalue (natural frequency square) matrix and "V" is the eigenvector (mode shapes) matrix.
To find eigenpairs in MATLAB, I use the command [V,phi] = eig(K,M). This produces the two matrices for me but the problem is that they are not in order.
It is known that the first eigenvalue is the lowest and it will increase for the higher mode shapes. However, the response I get is not in any order. My problem is a 12 by 12, and the first 5 eigenvalues are decreasing and it will increase. I'm not sure what it means, and how can I get the result in the normal order, such that the first column contains the lowest eigenvalue and the rest will be increasing. Following are K and M matrices I use.
Thank you so much for your time and considerations.
k = [0.100000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00;0.000000E+00 0.100000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00;0.000000E+00 0.000000E+00 0.175087E+04 -0.324091E+03 -0.833333E+02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.412479E+03 0.412479E+03;0.000000E+00 0.000000E+00 -0.324091E+03 0.584201E+03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.833333E+02 0.412479E+03 -0.412479E+03;0.000000E+00 0.000000E+00 -0.833333E+02 0.000000E+00 0.112796E+03 0.294628E+02 0.000000E+00 0.000000E+00 -0.294628E+02 -0.294628E+02 0.000000E+00 0.000000E+00;0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.294628E+02 0.112796E+03 0.000000E+00 0.000000E+00 -0.294628E+02 -0.294628E+02 0.000000E+00 -0.833333E+02;0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.100000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00; 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 0.100000E+01 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00;0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.294628E+02 -0.294628E+02 0.000000E+00 0.000000E+00 0.170624E+04 -0.147314E+03 -0.583333E+03 0.000000E+00;0.000000E+00 0.000000E+00 0.000000E+00 -0.833333E+02 -0.294628E+02 -0.294628E+02 0.000000E+00 0.000000E+00 -0.147314E+03 0.289573E+03 0.000000E+00 0.000000E+00;0.000000E+00 0.000000E+00 -0.412479E+03 0.412479E+03 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.583333E+03 0.000000E+00 0.995812E+03 -0.412479E+03;0.000000E+00 0.000000E+00 0.412479E+03 -0.412479E+03 0.000000E+00 -0.833333E+02 0.000000E+00 0.000000E+00 0.000000E+00 0.000000E+00 -0.412479E+03 0.495812E+03];
m = [0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.7118E+02 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.7118E+02 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00; 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.6069E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.6069E+01 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.5137E+02 0.0000E+00 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.5137E+02 0.0000E+00 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.4942E+02 0.0000E+00;0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.0000E+00 0.4942E+02];

  0 Comments

Sign in to comment.

2 Answers

Answer by Christine Tobler on 17 Aug 2018
 Accepted Answer

To sort the eigenvalues to be increasing in magnitude, use the following:
[U, d] = eig(k, m, 'vector');
[d, ind] = sort(d);
U = U(:, ind);
The eig function doesn't sort the eigenvalues it returns, for two reasons:
1) This is not needed for many applications, and would slow down the computation time for these cases. 2) For non-symmetric eigenvalue problems, the eigenvalues are complex, and none of the sorting methods for complex values are very satisfactory.
For symmetric problems (for the generalized case, this means both matrices are symmetric, and the second matrix is also positive definite), the eigenvalues are typically returned in ascending order by eig, but this is not a guarantee.

  0 Comments

Sign in to comment.


Answer by Steven Lord
on 17 Aug 2018

The "Sorted Eigenvalues and Eigenvectors" example on the documentation page for the eig function calls sort with two outputs to sort the eigenvalues (the sorted eigenvalues will be the first output from sort) then uses that second output from sort to reorder the matrix of eigenvectors to match the new order of the eigenvalues.

  0 Comments

Sign in to comment.