How do I threshold only real part of a complex matrix?
조회 수: 2 (최근 30일)
이전 댓글 표시
For a complex matrix how do I threshold only the real part of its elements to zero if I have complex matrix A, A(real(A)>0.5)=0 will make the entire complex matrix elements with real part greater than 0.5 as zero but not specifically the real part. How to do that in a single line?
댓글 수: 0
채택된 답변
Stephen23
2018년 8월 14일
편집: Stephen23
2018년 8월 14일
>> A = complex(randi([-3,3],4,4),randi([-3,3],4,4)) % fake data
A =
-2 + 3i -2 + 1i 2 - 3i -2 + 1i
-2 + 0i 3 + 0i -3 + 3i 0 + 0i
2 + 0i 2 - 2i 3 + 3i 0 - 3i
1 - 2i -3 - 2i 3 + 2i 0 - 2i
>> B = complex(real(A).*(real(A)<=0.5),imag(A)) % set real(A)>0.5 to 0.
B =
-2 + 3i -2 + 1i 0 - 3i -2 + 1i
-2 + 0i 0 + 0i -3 + 3i 0 + 0i
0 + 0i 0 - 2i 0 + 3i 0 - 3i
0 - 2i -3 - 2i 0 + 2i 0 - 2i
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!