Remove Terms in Complex Valued Data That Has Only Real or Imaginary Part
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MarshallSc
el 13 de Jun. de 2022
Comentada: Voss
el 13 de Jun. de 2022
I have a complex numeric array (file attached) that some of its terms have only real or imaginary part, and the rest have both the real and imaginary part. How can I remove the terms in the array that has only one term (real or imaginary) so that the terms that has both real and imaginary are left in the array? For example, for the first 8 rows of the data, I want to remove the first 7 terms:
0.000 + 0.254i
0.000 + 0.317i
0.000 + 0.298i
-0.0467 + 0.000i
0.000 + 0.317i
0.000 + 0.401i
0.000 + 0.437i
-0.0453 + 0.0029i % only this term is needed
Thank you!
0 comentarios
Respuesta aceptada
Voss
el 13 de Jun. de 2022
Editada: Voss
el 13 de Jun. de 2022
load LR
disp(LR);
One way:
% remove elements of LR whose real part is 0 or imaginary part is 0
LR(real(LR) == 0 | imag(LR) == 0) = [];
disp(LR);
Another way:
load LR
% keep elements of LR whose real part is non-zero and imaginary part is non-zero
LR = LR(real(LR) ~= 0 & imag(LR) ~= 0);
disp(LR)
load LR
% same but more concise:
LR = LR(real(LR) & imag(LR));
disp(LR)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!