dont want the number if its a part of a complex number
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Brian S.
am 23 Okt. 2019
Bearbeitet: Brian S.
am 23 Okt. 2019
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.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Bhaskar R
am 23 Okt. 2019
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 Kommentar
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!