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에서 Fourier Analysis and Filtering에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!