Here is the the vector i Have
r =
-1.6659 + 0.0000i
-0.3049 + 1.1564i
-0.3049 - 1.1564i
1.1378 + 0.3231i
1.1378 - 0.3231i
I am trying to check which elements are real numbers by means of a code, then after i'll have to calculate the percentage of those that are imaginary. Pls help
Thank You.

 採用された回答

John D'Errico
John D'Errico 2019 年 4 月 8 日
編集済み: John D'Errico 2019 年 4 月 8 日

0 投票

What does the function imag return?
Given that, what would
imag( r ) ~= 0
tell you? see that it returns a true or false value for each element.
Now, how would you compute the fraction of imaginary elements? That seems simple, since you can write things like
sum(imag( r ) ~= 0)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Performance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by