Can filter function be replace by a fft/ifft operation?
6 views (last 30 days)
Show older comments
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?
0 Comments
Answers (1)
Honglei Chen
on 14 Jul 2014
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 Comments
Honglei Chen
on 15 Jul 2014
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.
See Also
Categories
Find more on Frequency Transformations 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!