output filter from bandpass function
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tally
am 16 Mai 2018
Beantwortet: Star Strider
am 16 Mai 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 Kommentare
Akzeptierte Antwort
Star Strider
am 16 Mai 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!