Lets assume I want to apply a matched filter h
which is non-symmetric to my signal x
and the output is y
in matlab:
y=filter(h,1,x);
Now I am interested in comparing the information between my filtered signal y
and my input x
. For this I want to compensate for the delay of the filter h
.
When googling this topic I found the following tutorial which handles linear-phase fir filters. Obviously in such a case the group delay is $\frac{N-1}{2}$ given that the filter has the length $N$.
%this is the example from matlab
delay = mean(grpdelay(h,1,128));
x = x(1:end-delay);
y(1:delay) = [];
However, I am aware that the group delay of a non symmetric filter is frequency depending and I am not sure how to proceed to align my signals in time to compare them. As I am interested in real time application the function filtfilter
is not applicable.
So my question is, how do I estimate in the best way the time delay to align (sync?) my signals in time given the coefficients of a non-symmetric filter h
?
delay = .... h ....?
x = x(1:end-delay);
y(1:delay) = [];
The desired output should look like the red curve in the following figure
Here the signal in blue is the input signal x
and in green the filtered signal y
. However, I would like to to compensate for the delay of the green signal so that the input and output align in time as in the case of the red curve.