Remove Terms in Complex Valued Data That Has Only Real or Imaginary Part
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Voss
le 13 Juin 2022
Modifié(e) : Voss
le 13 Juin 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!