Sign in

username or email:

password:



Not a member?
Forgot your password?

Search code



Search tips


See Also

Embedded SystemsFPGA

DSP Code Sharing > Digital Comb Filter

Digital Comb Filter

Language: Matlab

Processor: Not Relevant

Submitted by on Jun 21 2011

Licensed under a Creative Commons Attribution 3.0 Unported License

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.

Comb Filter Response

 
% 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];
 
 
Rate this code snippet:
0
Rating: 0 | Votes: 0
 
   
 
posted by



Comments


No comments yet for this code


Add a Comment
You need to login before you can post a comment (best way to prevent spam). ( Not a member? )