why does my data kick up at the end after doing ifft(X)
8 次查看(过去 30 天)
显示 更早的评论
I have some data that I am doing a fft one, then filtering, then want to turn it back into the original domain, but when I do there is a 'kick' at the end of the data. I've followed what I can of the help functions for fft & ifft, but this is not detailed in there (that I can determine)
This is the code:
W = data(1,1:1024);
fs = 1;
L = length(W);
f = (0:L-1. fs*/L;
Y = fft(W);
Y1 = Y(1:512); % take just first half
filt_5 = ones(1, 5)/5;
f_delay = (length(filt_5)-1)/2;
filt_W_fft = filter(filt_5, 1, Y1);
YY = ifft(filt_W_fft);
And this is what I get:
In the top subplot, the purple curve is the result of the ifft - why does it have the upkick in data at ~1000 point mark? And how do I get rid of it?
Am I doing something wrong with the fft/ifft implementation?
Thanks in advance for any help or guidance.
3 个评论
Paul
2022-11-23
移动:Matt J
2022-11-23
Hi Joanne
It will be easier for people to help if you post the data. Use the paper clip icon to attach it to your question as a .mat file or some other format.
Having said that, it looks like you're applying a moving average filter to the FFT of W. Are you sure that's what you want to do? I'm asking because filter is typically used to filter a time domain signal, not a frequency domain signal.
回答(1 个)
Matt J
2022-11-23
编辑:Matt J
2022-11-23
why does my data kick up at the end
Remember, because of the circulant property of IFFTs, the values near the end of the array correspond to times just slightly prior to time t=0 (unless you apply fftshift).
By throwing away the second half of the spectrum in this line,
Y1 = Y(1:512); % take just first half
you are in effect applying a rect window to the spectrum, which is equivalent to convolving the original time signal W with a sinc kernel. So, even though your initial signal W starts at t=0, your operations will blur W so that negative times t<0 will have non-zero signal values as well. These new values are what you see at the end of YY.
And how do I get rid of it?
Don't throw away half of your spectrum.
2 个评论
Matt J
2022-12-5
Do you need fftshift? I'm not sure you do. I certainly never sugggested. Looking again at your code, though, it is possible that smoothdata expects Y1 to be unwrapped:
filt_W_fft = ifftshift( smoothdata(fftshift(Y1),'gaussian',5) );
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!