Ordering the eigenvalues in Matlab

  • Context: MATLAB 
  • Thread starter Thread starter brydustin
  • Start date Start date
  • Tags Tags
    Eigenvalues Matlab
Click For Summary
SUMMARY

In MATLAB, the function eig(Matrix) typically returns eigenvalues ordered from least to greatest. However, users have reported instances where eigenvalues are arranged by magnitude, resulting in unexpected outputs. To restore the default ordering, users can apply the sort function to the eigenvalues, using the syntax e = sort(eig(your_array)). The behavior of the eig function may vary based on the matrix type, but real eigenvalues should consistently follow the default ordering.

PREREQUISITES
  • Understanding of MATLAB programming environment
  • Familiarity with eigenvalues and eigenvectors
  • Knowledge of matrix types (e.g., orthogonal, symmetric)
  • Basic sorting algorithms in programming
NEXT STEPS
  • Explore MATLAB's eig function documentation for advanced options
  • Learn about matrix properties affecting eigenvalue computation
  • Investigate the implications of complex eigenvalues in MATLAB
  • Practice sorting techniques in MATLAB for different data types
USEFUL FOR

Mathematics students, MATLAB users, data scientists, and engineers working with linear algebra and eigenvalue problems.

brydustin
Messages
201
Reaction score
0
Normally when I work in matlab, the eigenvalues of a matrix are arranged in order from least to greatest when I call the function eig(Matrix).

But for some reason, Matlab has decided to start arranging them in order of magnitude (greatest to least)... so that it would arrange the following arbitrary eigenvalues {-3,4,0,-5,6} as:
{6,-5,4,-3,0} rather than the default (smallest to largest with respect to value NOT magnitude): i.e. {-5, -3, 0, 4,6}

Is there a way to put it back? Also, could it be the data type (for example, can certain matrices like orthogonal or symmetric or complex etc... change the way that eig spits out). I'm dealing with real eigenvalues (obviously there is no "standard ordering" of complex numbers (with imaginary parts).
Finally, ... is there really a "default" listing? I know if I take eig([1 0; 0 -1]) it will give {-1,1} every time, for example.
Thanks to all!
 
Physics news on Phys.org

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
Replies
11
Views
6K
  • · Replies 4 ·
Replies
4
Views
7K
  • · Replies 3 ·
Replies
3
Views
25K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K