Output only numbers with complex conjugate
이전 댓글 표시
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.
채택된 답변
추가 답변 (1개)
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
Star Strider
2020년 11월 24일
Rik
2020년 11월 24일
Wouldn't that just return an error when used on a? Or do you mean this?
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=cplxpair(c);
e=d(2:2:end)
Ko Fa
2020년 11월 24일
Rik
2020년 11월 24일
You can also use the 'stable' option in unique if you want to preserve the original order.
Ko Fa
2020년 11월 24일
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!