]> Creatis software - CreaPhase.git/blob - octave_packages/signal-1.1.3/kaiser.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / signal-1.1.3 / kaiser.m
1 ## Copyright (C) 1995, 1996, 1997 Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at>
2 ## Copyright (C) 2000 Paul Kienzle <pkienzle@users.sf.net>
3 ## 
4 ## This program is free software; you can redistribute it and/or modify it under
5 ## the terms of the GNU General Public License as published by the Free Software
6 ## Foundation; either version 3 of the License, or (at your option) any later
7 ## version.
8 ##
9 ## This program is distributed in the hope that it will be useful, but WITHOUT
10 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12 ## details.
13 ##
14 ## You should have received a copy of the GNU General Public License along with
15 ## this program; if not, see <http://www.gnu.org/licenses/>.
16
17 ## usage:  kaiser (L, beta)
18 ##
19 ## Returns the filter coefficients of the L-point Kaiser window with
20 ## parameter beta.
21 ##
22 ## For the definition of the Kaiser window, see A. V. Oppenheim &
23 ## R. W. Schafer, "Discrete-Time Signal Processing".
24 ##
25 ## The continuous version of width L centered about x=0 is:
26 ##
27 ##         besseli(0, beta * sqrt(1-(2*x/L).^2))
28 ## k(x) =  -------------------------------------,  L/2 <= x <= L/2
29 ##                besseli(0, beta)
30 ##
31 ## See also: kaiserord
32
33 function w = kaiser (L, beta = 0.5)
34
35   if (nargin < 1)
36     print_usage;
37   elseif !(isscalar (L) && (L == round (L)) && (L > 0))
38     error ("kaiser:  L has to be a positive integer");
39   elseif !(isscalar (beta) && (beta == real (beta)))
40     error ("kaiser:  beta has to be a real scalar");
41   endif
42   
43   if (L == 1)
44     w = 1;
45   else
46     m = L - 1;
47     k = (0 : m)';
48     k = 2 * beta / m * sqrt (k .* (m - k));
49     w = besseli (0, k) / besseli (0, beta);
50   endif
51
52 endfunction
53
54 %!demo
55 %! % use demo("kaiserord");