dont want the number if its a part of a complex number

조회 수: 1 (최근 30일)
Brian S.
Brian S. 2019년 10월 23일
편집: Brian S. 2019년 10월 23일
So I know that doing;
Z = [0.5i 1+3i -2.2];
X = real(Z)
would give me
X = 0 1.0000 -2.2000
but what should I do if I only want pure real numbers and not even the real part of the complex number?
for example;
Z = [0.5i 1+3i -2.2];
"..."
would give me
X = 0 0 -2.2000
Thanks any help is appreciated.

채택된 답변

Tanveer ul haq
Tanveer ul haq 2019년 10월 23일
Z = [0.5 1+3i -2.2];
Z(~imag(Z))

추가 답변 (1개)

Bhaskar R
Bhaskar R 2019년 10월 23일
MATALB convert all numbers float if any number is float in the array as it Auto type cast so we need to convert from the manipulation as shown
flag = abs(real(Z)) == abs(Z);
X = real(Z).*flag;
  댓글 수: 1
Brian S.
Brian S. 2019년 10월 23일
편집: Brian S. 2019년 10월 23일
not exactly the method I was going for but it did answer the question, thanks a ton

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

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by