% combs.m
%
% A Matlab script to plot comb filter amplitude responses.
%
% Gary Scavone, McGill University, 2004.

% Signal and delay values.
N = 100;
omega = pi*(0:N)/N;
M = 5;

% Feedforward coefficient values.
b0 = 1;
bm = [0.1 0.5 0.9];

% Calculate the feedforward filter frequency response.
Gf = b0 + transpose(bm)*exp(-j*M*omega);

plot(omega/pi, 20*log10(abs(Gf)))
grid
xlabel('Normalized Radian Frequency');
ylabel('Magnitude Response (dB)');
legend('b_{M} = 0.1', 'b_{M} = 0.5', 'b_{M} = 0.9');

disp('paused ... hit key to continue');
pause

% Feedback coefficient values.
b0 = 1;
am = -[0.1 0.5 0.9];

% Calculate the feedback filter frequency response.
Gb = b0 ./ (1 + transpose(am)*exp(-j*M*omega));

plot(omega/pi, 20*log10(abs(Gb)))
grid
xlabel('Normalized Radian Frequency');
ylabel('Magnitude Response (dB)');
legend('a_{M} = -0.1', 'a_{M} = -0.5', 'a_{M} = -0.9');
