Output only numbers with complex conjugate

2 visualizaciones (últimos 30 días)
Ko Fa
Ko Fa el 24 de Nov. de 2020
Comentada: Ko Fa el 24 de Nov. de 2020
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.

Respuesta aceptada

Bruno Luong
Bruno Luong el 24 de Nov. de 2020
a(ismember(a,conj(a))&imag(a)>=0)

Más respuestas (1)

Rik
Rik el 24 de Nov. de 2020
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)
e = 1×2
1.0000 + 0.1000i 10.0000 + 0.2000i
(the displaying seems to have some issues, but it is indeed the vector you describe)
  5 comentarios
Rik
Rik el 24 de Nov. de 2020
You can also use the 'stable' option in unique if you want to preserve the original order.
Ko Fa
Ko Fa el 24 de Nov. de 2020
True! Thank you.

Iniciar sesión para comentar.

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by