I've designed an IIR bandpass elliptic filter in Scilab with the following parameters.
- Sampling Frequency = 25000 Hz
- Lower cutoff frequency = 100 Hz
- Upper cutoff frequency = 150 Hz
- Pass band ripple = stop band ripple = 0.001 ~ 0.005 dB
When I compute the group delay of this filter, I get a value of about 31 samples at a frequency of 125 Hz.
However, when I filter a 125Hz signal using the flts function, I see that the delay doesn't really line up with the number 31.
If the group delay was 31 samples, shifting the output signal back by that number would align it with the input signal which is the behavior I've seen with all FIR filters (N -1 / 2). Of course, the group delay doesn't vary with frequency in FIR filters but I'm looking at just this one frequency (125 Hz) at the moment.
Is the group delay correct? If so, why wouldn't the output align with the input if it is shifted? Given below is the full Scilab code.
Fs = 25000;
Flp = 100;
Fhp = 150;
filterTf = iir(3,'bp','ellip',[Flp/Fs Fhp/Fs],[0.001 0.005]);
figure("BackgroundColor",'1|1|1');
bode(syslin(1/Fs,filterTf),0.01:0.05:Fs/2);
t = 0 : 1/Fs : 0.1;
inputSignal = 10 * sin(2 * %pi * 125 * t);
filteredSignal = flts(inputSignal,filterTf);
figure("BackgroundColor",'1|1|1');
xtitle('Signals','Samples','Signals');
plot(inputSignal,'r-','LineWidth',2);
plot(filteredSignal, 'k-','LineWidth',2);
legend(["Input Signal";"Filtered Signal"],"out_upper_right");
xgrid(1);
figure("BackgroundColor",'1|1|1');
[tg,fr] = group(25000,filterTf);
plot(fr,tg);
xgrid(1);