How can I separate complex numbers from the other in a matrix?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
the cyclist
2019년 5월 10일
편집: the cyclist
2019년 5월 10일
% 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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!