Can filter function be replace by a fft/ifft operation?
显示 更早的评论
Can filter function be replace by a fft/ifft operation?
for example:
out = filter(LPF,in);
replaced by:
one = ifft(ones(size(in))); oneout = filter(LPF,one); f_oneout = fft(oneout); out = ifft(f_oneout.*fft(in));
Is there any difference between these two? As I want the second result. But I just dont know why these are different?
回答(1 个)
Honglei Chen
2014-7-14
I don't understand your approach of fft/ifft to filter the signal, so I cannot comment on that. But between filter and fft/ifft approach, it is important to realize that fft/ifft approach is equivalent to circular convolution while filter corresponds to linear convolution, so you need to be careful regarding the number of points
for example:
LPF = [1 1]
in = ones(1,10)
filter(LPF,1,in)
ifft(fft(LPF,length(in)).*fft(in))
See the difference. Now do
y = ifft(fft(LPF,length(in)+length(LPF)-1).*fft(in,length(in)+length(LPF)-1))
y(1:length(in))
Now it's the same as filter result.
HTH
4 个评论
Marco
2014-7-14
Not wanting to hijack the thread, but what is the difference between linear and circular convolution? Would you have a link for further reading about that? Thanks!
Honglei Chen
2014-7-14
Here is an example you can take a look
Essentially, you can imagine to stack the linear convolution result at every N points so the result becomes periodic with a period of N. Circular convolution simply extracts one period of the result.
JIN
2014-7-15
Honglei Chen
2014-7-15
filter is doing the right thing. In many applications, the number of outputs is the same as the number of inputs. You can use state with filter to achieve streaming. If you want to see the entire result and you have access for all the data, then you can consider using conv.
类别
在 帮助中心 和 File Exchange 中查找有关 Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!