L = 3;

hh = ones(1,L)/L;

inc = 0.05;
fd = 0:inc:0.5;

nn = 0:1:2/inc;

amp = zeros(size(fd));

for kk=1:length(fd)
   xx = cos(2*pi*fd(kk)*nn);
   yy = conv(xx,hh);
   
    plot(yy);
    title(sprintf('Freq: %0.5g', fd(kk)));
    grid
    
    pause(1)
   
   amp(kk) = max(yy(L:end-L));
end

plot(fd,amp)
grid
xlabel('Frequency f_d');
ylabel('Amplitude');