Output only numbers with complex conjugate
1 回表示 (過去 30 日間)
古いコメントを表示
Lets say I have an Array
a = [1+i*0.1, 1-i*0.1, 5-i*0.1, 10+i*0.2, 10-i*0.2]
which only contains complex numbers. I would like my output to only contains those numbers which have an corresponding complex conjugate inside the array e.g.
out = [1+i*0.1 10+i*0.2]
The output could also just contain the complex conjugate, but not both
Any help is greatly appreciated.
0 件のコメント
採用された回答
その他の回答 (1 件)
Rik
2020 年 11 月 24 日
a = [1+1i*0.1, 1-1i*0.1, 5-1i*0.1, 10+1i*0.2, 10-1i*0.2];
b=conj(a);
c=b(ismember(b,a));
d=real(c)+1i*abs(imag(c));
e=unique(d)
(the displaying seems to have some issues, but it is indeed the vector you describe)
5 件のコメント
Rik
2020 年 11 月 24 日
You can also use the 'stable' option in unique if you want to preserve the original order.
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!