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 日
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
Paul Rogers 2020 年 7 月 18 日
nope
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 日

0 投票

vectors = [phi, psi];
vectors(4865:end, :)

3 件のコメント

Paul Rogers
Paul Rogers 2020 年 7 月 18 日
thank, but in this case real numbers happen to start at 4865, they could start before or laterr depending on the case
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, :)
Paul Rogers
Paul Rogers 2020 年 7 月 18 日
nope

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2014b

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by