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

조회 수: 8 (최근 30일)
Paul Rogers
Paul Rogers 2020년 7월 18일
댓글: Walter Roberson 2020년 7월 18일
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
Walter Roberson
Walter Roberson 2020년 7월 18일
"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.

댓글을 달려면 로그인하십시오.

채택된 답변

madhan ravi
madhan ravi 2020년 7월 18일
vectors = [phi, psi];
vectors(4865:end, :)
  댓글 수: 3
madhan ravi
madhan ravi 2020년 7월 18일
phi_psi = [phi, psi];
ix = imag([phi, psi]) == 0;
idx = find(all(ix, 2), 1);
Wanted = phi_psi(idx : end, :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gamma Functions에 대해 자세히 알아보기

태그

제품


릴리스

R2014b

Community Treasure Hunt

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

Start Hunting!

Translated by