extracting only real numbers (not real part) from a vector
Ältere Kommentare anzeigen
I have these 2 vector, phi, and psi.
both have complex number from the 1st to 4864th element, then from 4865th to the last real number.
I'd like to turn phi into a vector, let's say a, and psi, b, which contains only the valus that are real.
Like this the attached files:
3 Kommentare
Walter Roberson
am 18 Jul. 2020
a = phi(imag(phi) == 0);
b = psi(imag(psi) == 0);
However, I would suspect that you need more like
mask = imag(phi) == 0 & imag(psi) == 0;
a = phi(mask);
b = psi(mask);
Paul Rogers
am 18 Jul. 2020
Walter Roberson
am 18 Jul. 2020
"both have complex number from the 1st to 4864th element,"
That is not correct: psi and phi both start with 0, which is not a complex number.
"both have complex number from the 1st to 4864th element, then from 4865th to the last real number."
No, the first element (after the very first) with imaginary part 0 is element 4858.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!