Digital Comb Filter
This code snippet will generate numberator(b) and denominator(a) coefficients for a comb filter. (http://en.wikipedia.org/wiki/Comb_filter )
In reality, this code snippet is geared towards simulation purposes and is not recommended for a direct implemenation. The reason is that in order to simultate the delay of "x", the b coefficients have alot of zero's in them and you would not want to waste the instructions on multiplying by zero. What is nice about this code is that you can very easily plug it into the filter() function for a quick-and-easy comb filter of your signal.
This could be used as a DC blocker if you set the gain to a negative value. If you are comparing this code to the wikipedia article, "scalar" is the same as alpha and "order" is the same as K.
% Usage: [B,A] = COMB(order, scalar);
%
% ORDER is the number of samples delayed prior to add
% SCALAR is the coefficient that will be applied to
% the delayed signal path at the final summation block.
%
% Note, there are two types of comb filters. A DC-blocker and a DC-passer.
% To get a DC-Blocker (tooth at DC), pass in a -1 for the scalar.
% To get a DC-Passer (+6dB at DC), pass in a +1 for the scalar.
%
% By default, if the scalar is not passed, a DC-Passer is assumed.
%
% Author: sparafucile17 03/16/04
% Validate that the proper argument count was supplied
error(nargchk(1, 2, nargin));
% Use scalar is passed as an argument, otherwise assume scalar=1;
if (nargin == 1)
scalar = 1;
else
scalar = varargin{1};
end
% Input has zeros to simulate a single delay of N samples
a = [ 1 ];
b = [ 1 zeros(1, N-1) scalar*1];