By default eig would not always return the eigenvalues and eigenvectors in sorted order. Use the sort purpose to put the eigenvalues in ascending get and reorder the corresponding eigenvectors. The entries within the diagonal of a Hermitian matrix are usually serious. For the reason that actual matrices are unaffected https://johnnytfdwd.blogolize.com/top-guidelines-of-hire-sameone-to-do-matlab-assignment-69046228