How to seperate complex numbers based on imaginary values.

Hi, I am using eig(A) to find eigen values of a 8x8 matrix. There are 8 eigen values for the matrix. But only four of them are complex numbers while the other four are pure real numbers. I need only the values with imaginary parts for my further computations. How do I seperate them? Thanks.

 採用された回答

Walter Roberson
Walter Roberson 2017 年 9 月 25 日

0 投票

K = rand(8) ;
E = eig(K) ;
E = E(imag(E) ~= 0);
Note, though, that eigenvalues should be entirely real can end up with a small imaginary component due to round-off error. You might want to use something like
tolerance = 1e-10;
E = E( abs(imag(E)) <= tolerance );

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNumeric Types についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by