Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
D_coder
D_coder el 14 de Ag. de 2018
Abierta de nuevo: Walter Roberson el 22 de Dic. de 2018
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?

Respuesta aceptada

Stephen23
Stephen23 el 14 de Ag. de 2018
Editada: Stephen23 el 14 de Ag. de 2018
>> 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

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by