How can I separate complex numbers from the other in a matrix?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
masoud jiryaei
am 10 Mai 2019
Kommentiert: the cyclist
am 18 Jun. 2019
Hello
I have a matrix that includes: complex numbers , natural numbers and ...
I want to separate the complex numbers from the other
How can I do this ?
Is there any order in MATLAB ?
0 Kommentare
Akzeptierte Antwort
the cyclist
am 10 Mai 2019
Bearbeitet: the cyclist
am 10 Mai 2019
% Example data
z = [1 1+2*i 3 4+5*i]
mask = imag(z)==0;
The variable mask is a logical variable that is TRUE at the locations of the numbers that do not have an imaginary component, and FALSE otherwise.
You'll need to be careful if you have imaginary parts that are within floating-point precision of zero. You might need to use a tolerance, rather than strict equality.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical 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!