I have a complex array in Matlab
x = [2+1i, 0.1+3i, 0.001+4i, 5+0.0002i, 6+0.0013i]
and I want to make the real or imaginary parts equal to zero if they are smaller than some tolerance.
For example, if the real tolerance is 0.01 and imaginary tolerance is 0.001, then after the operation my array should look like this:
x = [2+1i, 0.1+3i, 0+4i, 5+0i, 6+0.0013i]
Of course I can split x into its real and imaginary parts, round them independently and then join them back. However, the actual arrays are quite big (100k*100k) each I don't want to waste memory doing this.
Is there a way to round the individual parts of a complex array without splitting it in two?