output filter from bandpass function
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tally
el 16 de Mayo de 2018
Respondida: Star Strider
el 16 de Mayo de 2018
Hi, I am using the bandpass function in the following code:
Fs = 10;
t = 1:(1/Fs):200;
s = sin(2*pi*0.1*t) + sin(2*pi*0.5*t);
[y,d] = bandpass(s,[0.06,0.12],Fs);
y2 = filter(d,s);
According to matlab documentation d is the Bandpass filter used in the filtering operation, returned as a digitalFilter object. So I expect y2 to be equal to y1, however they are very different. My questions are: 1. Why y2 is different than y1? 2. How can I use d to obtain exactly y1? Thanks,
0 comentarios
Respuesta aceptada
Star Strider
el 16 de Mayo de 2018
The filter function will only return the same result as ‘y’ (or ‘y1’) for linear-phase FIR filters such as those produced by the fir1 function. For IIR filters, the default design of the bandpass function, you must use the phase-neutral filtfilt function, as I suspect the bandpass function uses by default.
I will let you explore those functions at your leisure.
Your code (with my slight modifications) becomes:
Fs = 10;
t = 1:(1/Fs):200;
s = sin(2*pi*0.1*t) + sin(2*pi*0.5*t);
[y,d] = bandpass(s,[0.06,0.12],Fs);
y2 = filtfilt(d,s);
figure(1)
plot(t, s, t, y2, t, y)
figure(2)
plot(t, y2, '-', t, y, '--')
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Digital Filter Design en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!