extracting only real numbers (not real part) from a vector

5 vues (au cours des 30 derniers jours)
Paul Rogers
Paul Rogers le 18 Juil 2020
Commenté : Walter Roberson le 18 Juil 2020
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 commentaires
Paul Rogers
Paul Rogers le 18 Juil 2020
nope
Walter Roberson
Walter Roberson le 18 Juil 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.

Connectez-vous pour commenter.

Réponse acceptée

madhan ravi
madhan ravi le 18 Juil 2020
vectors = [phi, psi];
vectors(4865:end, :)
  3 commentaires
madhan ravi
madhan ravi le 18 Juil 2020
phi_psi = [phi, psi];
ix = imag([phi, psi]) == 0;
idx = find(all(ix, 2), 1);
Wanted = phi_psi(idx : end, :)
Paul Rogers
Paul Rogers le 18 Juil 2020
nope

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by