comparison m-toolbox/classes/@miir/mkallpass.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % MKALLPASS returns an allpass filter miir().
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: MKALLPASS returns an allpass filter miir().
5 %
6 % CALL: f = mkallpass(f, pl)
7 %
8 % VERSION: $Id: mkallpass.m,v 1.2 2010/10/29 16:09:14 ingo Exp $
9 %
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12 function f = mkallpass(f, pl)
13
14 fs = find(pl, 'fs');
15 method = find(pl, 'method');
16 D = find(pl, 'delay');
17 N = find(pl, 'N');
18
19 % Build filter coefficients
20 switch method
21 case 'thirlen'
22 for k=0:N
23 a(k+1) = (-1.0)^k * factorial(N)/(factorial(k)*factorial(N-k));
24 for n=0:N
25 a(k+1) = a(k+1) * (D-N+n)/(D-N+k+n);
26 end
27 end
28
29 a = a/sum(a);
30 b(1) = 1;
31
32 otherwise
33 error(['Unrecognised method [' method ']']);
34 end
35
36 % Set filter properties
37 f.name = 'bandpass';
38 f.fs = fs;
39 f.a = a;
40 f.b = b;
41 f.histin = zeros(1,f.ntaps-1); % initialise input history
42 f.histout = zeros(1,f.ntaps-1); % initialise output history
43 end
44