フィルターのクリア

How do I threshold only real part of a complex matrix?

2 ビュー (過去 30 日間)
D_coder
D_coder 2018 年 8 月 14 日
再開済み: Walter Roberson 2018 年 12 月 22 日
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?

採用された回答

Stephen23
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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by