```On Jan 24, 7:28&#2013266080;pm, Dirk Bell <bellda2...@cox.net> wrote:
> On Jan 23, 2:44&#2013266080;am, Rune Allnor <all...@tele.ntnu.no> wrote:
>
>
>
>
>
> > On Jan 23, 3:02&#2013266080;am, "whitehat09" <whitehat09@n_o_s_p_a_m.gmail.com>
> > wrote:
>
> > > Hi everyone,
> > > I searched around and couldnt quite find a problem like this, so sorry if
> > > there is a similar post already.
>
> > > In matlab I generate a simple 4th order butterworth filter, code below:
>
> > > &#2013266080; &#2013266080; [B,A]=butter(4,Wn,'low');
> > > &#2013266080; &#2013266080; yf=filter(B,A,y);
>
> > > Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
>
> > > My question is ... how do I calculate the delay added by the filter? By
> > > delay I mean the extra samples that are added to the beginning of 'yf'.
>
> > There shouldn't be any. If there are, somebody did something wrong.
>
> > Mind you, the first few samples might be of such low amplitude
> > that you don't notiuce them, in which case you are looking
> > for ways to compute the group delay.
>
> > Look up a text on DSP on how to actually do the computation.
>
> > Rune
>
> Rune,
>
> Why should there be no delay? The filter has non-linear phase so the
> impulse response has frequency dependent delay.

It has a frequency dependent *group* delay.

> What am I missing?

That the term 'delay' is ambiguous in the context. It could
also mean that there is no response at the output until after
a number of samples after the input was excited.

Rune
```
```On Jan 22, 8:02=A0pm, "whitehat09" <whitehat09@n_o_s_p_a_m.gmail.com>
wrote:
> Hi everyone,
> I searched around and couldnt quite find a problem like this, so sorry if
> there is a similar post already.
>
> In matlab I generate a simple 4th order butterworth filter, code below:
>
> =A0 =A0 [B,A]=3Dbutter(4,Wn,'low');
> =A0 =A0 yf=3Dfilter(B,A,y);
>
> Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
>
> My question is ... how do I calculate the delay added by the filter? By
> delay I mean the extra samples that are added to the beginning of 'yf'. I=
ts
> been a while since Ive done any filter theory so Im having a difficult ti=
me
> finding answers. Just by eye-balling the difference of 'y'=A0to 'yf' I th=
ink
> the delay =3D 1/Wn but cannot find any material to support this. So am I
> wrong? Is there a better way to calculate the delay? Any help is
> appreciated.
>
> Thanks

Sorry I didn't answer this earlier, but I have been away from my
computer the last 4 days.
I just ran your code in Matlab and saw no delay in the output, nor did
I see extra samples added to the beginning of yf. Waht are you using
for 'y'?

Maurice Givens
```
```On Jan 23, 2:44=A0am, Rune Allnor <all...@tele.ntnu.no> wrote:
> On Jan 23, 3:02=A0am, "whitehat09" <whitehat09@n_o_s_p_a_m.gmail.com>
> wrote:
>
> > Hi everyone,
> > I searched around and couldnt quite find a problem like this, so sorry =
if
> > there is a similar post already.
>
> > In matlab I generate a simple 4th order butterworth filter, code below:
>
> > =A0 =A0 [B,A]=3Dbutter(4,Wn,'low');
> > =A0 =A0 yf=3Dfilter(B,A,y);
>
> > Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
>
> > My question is ... how do I calculate the delay added by the filter? By
> > delay I mean the extra samples that are added to the beginning of 'yf'.
>
> There shouldn't be any. If there are, somebody did something wrong.
>
> Mind you, the first few samples might be of such low amplitude
> that you don't notiuce them, in which case you are looking
> for ways to compute the group delay.
>
> Look up a text on DSP on how to actually do the computation.
>
> Rune

Rune,

Why should there be no delay? The filter has non-linear phase so the
impulse response has frequency dependent delay.

What am I missing?

Dirk
```
```>On Jan 23, 3:02=A0am, "whitehat09" <whitehat09@n_o_s_p_a_m.gmail.com>
>wrote:
>> Hi everyone,
>> I searched around and couldnt quite find a problem like this, so sorry
if
>> there is a similar post already.
>>
>> In matlab I generate a simple 4th order butterworth filter, code below:
>>
>> =A0 =A0 [B,A]=3Dbutter(4,Wn,'low');
>> =A0 =A0 yf=3Dfilter(B,A,y);
>>
>> Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
>>
>> My question is ... how do I calculate the delay added by the filter? By
>> delay I mean the extra samples that are added to the beginning of 'yf'.
>
>There shouldn't be any. If there are, somebody did something wrong.
>
>Mind you, the first few samples might be of such low amplitude
>that you don't notiuce them, in which case you are looking
>for ways to compute the group delay.
>
>Look up a text on DSP on how to actually do the computation.
>
>Rune
>

Hi Rune,

If you use the code I listed before there definitely is a delay added to
the output, but I have since started using 'filtfilt' instead on 'filter'
because filfilt is a zero-phase filter. However I still cannot explain why
the samples added to yf from 'filter' is around 1/Wn.

```
```On Jan 23, 3:02=A0am, "whitehat09" <whitehat09@n_o_s_p_a_m.gmail.com>
wrote:
> Hi everyone,
> I searched around and couldnt quite find a problem like this, so sorry if
> there is a similar post already.
>
> In matlab I generate a simple 4th order butterworth filter, code below:
>
> =A0 =A0 [B,A]=3Dbutter(4,Wn,'low');
> =A0 =A0 yf=3Dfilter(B,A,y);
>
> Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.
>
> My question is ... how do I calculate the delay added by the filter? By
> delay I mean the extra samples that are added to the beginning of 'yf'.

There shouldn't be any. If there are, somebody did something wrong.

Mind you, the first few samples might be of such low amplitude
that you don't notiuce them, in which case you are looking
for ways to compute the group delay.

Look up a text on DSP on how to actually do the computation.

Rune
```
```Hi everyone,
I searched around and couldnt quite find a problem like this, so sorry if
there is a similar post already.

In matlab I generate a simple 4th order butterworth filter, code below:

[B,A]=butter(4,Wn,'low');
yf=filter(B,A,y);

Where 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

My question is ... how do I calculate the delay added by the filter? By
delay I mean the extra samples that are added to the beginning of 'yf'. Its
been a while since Ive done any filter theory so Im having a difficult time
finding answers. Just by eye-balling the difference of 'y'&nbsp;to 'yf' I think
the delay = 1/Wn but cannot find any material to support this. So am I
wrong? Is there a better way to calculate the delay? Any help is
appreciated.

Thanks

```