# Matlab group delay not corresponding to reality

I studying effects of digital filters group delay (IIR). In Matlab there is a function grpdelay which allows for particular frequency get a value of delay in samples

But after filter applying and comparing of pictures there are diffent results. In rude words if I expect 50 samples delay under grpdelay analysis, in fact I see 100 samples, If I expect 30, I see 70 and so on. What I doing wrong? I use simple sin processed gauss window for example

clear;
close all;

t = 0:0.008:600;

x = sin( 2 * pi * t * 1.3 ) .* gausswin(length(t) )';
x = [ zeros(1, 1000) x zeros(1, 1000) ];

fs = 125;
fc_low = 0.5;
fc_high = 3;
order = 4;

[b,a] = butter(order, [ fc_low/(fs/2), fc_high/(fs/2) ] );
y = filter(b, a, x);

plot(x)

hold on;

plot(y)

legend('orig', 'filtered')

figure;

grpdelay(b, a, 512, fs);


below there is example of theoretical and model misfitting  So, the result is that Matlab function grpdelay gives not accurate results or I have errors in calculation/interpretation ?

• The likelihood that a well established MATLAB function is wrong is extremely low, so chances are it's your code or interpretation. Please post your actual code you used to make the graphs. What you currently have in your are just a few fragments. – Hilmar Feb 2 at 14:45
• Thanks! I posted whole code – the_jack Feb 2 at 18:01
• Your picture suggests you have misunderstood group delay. You are apparently measuring phase delay. – Jazzmaniac Feb 2 at 18:22
• I don't think so. In Openheim book, chapter 5 there are the similar example and understanding of group delay as I did – the_jack Feb 2 at 18:40
• You should have a look here Phase/Group-Delay. – Irreducible Feb 3 at 6:19