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?

Respuestas (1)

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 comentarios

Marco
Marco el 14 de Jul. de 2014
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!
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
JIN el 15 de Jul. de 2014
Exactly! Thank you so much!
Do you think the filter function is not long enough to show the actual output of the data?
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.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

JIN
el 14 de Jul. de 2014

Comentada:

el 15 de Jul. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by