Finding the if the complex numbers with the imaginary part not equal to zero (array)

9 ビュー (過去 30 日間)
Daniel Zalivchi
Daniel Zalivchi 2020 年 4 月 14 日
コメント済み: Daniel Zalivchi 2020 年 4 月 14 日
So I'm trying to figure out a way to find the terms that have an imaginary part that is not equal to zero
The array:
sp =
-1.0000 + 0.0000i
-0.8090 + 0.5878i
-0.8090 - 0.5878i
-0.3090 + 0.9511i
-0.3090 - 0.9511i
I tried
x = sp(imag(sp)<0)
as a test, but why doesn't
y = sp(imag(sp)=0)
work

回答 (1 件)

James Tursa
James Tursa 2020 年 4 月 14 日
The equality conditional operator in MATLAB is the double equals ==, so
y = sp(imag(sp)==0)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by