How to replace complex numbers in a column vector with 0.000+0.000i ?
Show older comments
Image we obtain a fft of a signal and we wish to remove certain frequencies from the signal. I want to fill in zeros after removing certain rows of complex numbers. Filling in with zeros [0, 0, 0, 0] did not work because ifft was absurd. The real part and the imaginary part must be zeroed and it should appear like 0.0000+0.0000i. Is there a way to fill in 0000+0.0000i in desired regions of the FFT of the signal? What command should one use? Basically this is fft filtering.
Say fft(A) = [-0.0708535039155114 - 0.00736177322883826i, -0.0700055929768761 - 0.0329196686985671i, -0.0593736872430442 + 0.00109491019902367i,
-0.0435002106533236 + 0.0325121703659659i, -0.0605346303385998 - 0.000499071340404484i]
How should we convert that into by removing certain complex numbers and convert them into zero complex numbers?
[-0.0708535039155114 - 0.00736177322883826i, 0.000000 +0.0000000000i, 0.000000 +0.0000000000i, 0.000000 +0.0000000000i,- 0.000499071340404484i]
Thanks.
Accepted Answer
More Answers (1)
Suppose you have a complex vector (the result of your fft) lets call it x. If you want to replace some elements of it with zero (0 + 0i), you can just use for example to replace the 3rd and 4th and 6th element with zero
x = randn(10,1) + randn(10,1)*i
x([3 4 6])=0
which gives
0.2939 + 1.3703i
-0.7873 - 1.7115i
0.0000 + 0.0000i
0.0000 + 0.0000i
-1.0689 + 0.3192i
0.0000 + 0.0000i
-2.9443 - 0.8649i
1.4384 - 0.0301i
0.3252 - 0.1649i
-0.7549 + 0.6277i
Note that if the rest of the vector is complex, you can just assign the value 0 (no complex part) to the elements and it will make both the real and imaginary parts zero
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!