MATLAB: Need help for selectivity of filters based on filter length

filter

I have written this code for two filter lengths (L)
h770=[];
L=10;
fs=8000;
fb=770;
h770 = (2/L)*cos(2*pi*fb*(0:L-1)/fs);
ww=0:(pi/256):pi;
ff=ww/(2*pi)*fs;
H=freqz(h770,1,ww);
subplot(2,1,1)
plot(ff,abs(H));
title('Magnitude response for L=10 for h770')
grid on;
L=100;
h770 = (2/L)*cos(2*pi*fb*(0:L-1)/fs);
H=freqz(h770,1,ww);
subplot(2,1,2)
plot(ff,abs(H));
title('Magnitude response for L=100 for h770')
grid on;
Now the book asks, Notice the selectivity of filters based on filter length. Think about how this selectivity is used to pass one component while rejecting or attenuating the others.
Kindly explain this to me. what he mean by selectivity

Best Answer

Selectivity is referring to the width of the passband here. Notice where your filter magnitude goes to zero for L=10 vs. L=100. Look at the difference in the width of the two passbands.