function [y, b, a] = tapped_delay_line(x, n, g, d)
% A tapped delay function
% Input arguments:
% x - input signal
% n - number of taps (reflections)
% g - vector of gains for each tap
% d - vector of delay lengths for each tap % Output arguments:
%-Y - output signal:
%b - numerator coeff for TF
%a - denominator coeff for TF

max_delay=max(d);
a=1;
b=zeros(1,max_delay+1);
b(1)=1;

for i = 1:n
b(d(i)+1) = b(d(i)+1) + g(i); 
end
[impresp, lengthvector]=impz(b,a);
y=conv(x,impresp);
end

