3191
|
1 ## Copyright (C) 1995, 1996, 1997 Andreas Weingessel |
3426
|
2 ## |
3191
|
3 ## This program is free software; you can redistribute it and/or modify |
|
4 ## it under the terms of the GNU General Public License as published by |
|
5 ## the Free Software Foundation; either version 2, or (at your option) |
|
6 ## any later version. |
3426
|
7 ## |
3191
|
8 ## This program is distributed in the hope that it will be useful, but |
|
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3426
|
11 ## General Public License for more details. |
|
12 ## |
3191
|
13 ## You should have received a copy of the GNU General Public License |
|
14 ## along with this file. If not, write to the Free Software Foundation, |
|
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
16 |
3449
|
17 ## -*- texinfo -*- |
|
18 ## @deftypefn {Function File} {} bartlett (@var{m}) |
|
19 ## Return the filter coefficients of a Bartlett (triangular) window of |
|
20 ## length @var{m}. |
3191
|
21 ## |
|
22 ## For a definition of the Bartlett window, see e.g. A. V. Oppenheim & |
|
23 ## R. W. Schafer, "Discrete-Time Signal Processing". |
3449
|
24 ## @end deftypefn |
3191
|
25 |
3457
|
26 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> |
|
27 ## Description: Coefficients of the Bartlett (triangular) window |
3191
|
28 |
|
29 function c = bartlett (m) |
3426
|
30 |
3191
|
31 if (nargin != 1) |
|
32 usage ("bartlett (m)"); |
|
33 endif |
3426
|
34 |
3457
|
35 if (! (is_scalar (m) && (m == round (m)) && (m > 0))) |
|
36 error ("bartlett: m has to be an integer > 0"); |
3191
|
37 endif |
3426
|
38 |
3191
|
39 if (m == 1) |
|
40 c = 1; |
|
41 else |
|
42 m = m - 1; |
|
43 n = fix (m / 2); |
|
44 c (1 : n+1) = 2 * (0 : n)' / m; |
|
45 c (n+2 : m+1) = 2 - 2 * (n+1 : m)'/m; |
|
46 endif |
|
47 |
|
48 c = c'; |
|
49 |
|
50 endfunction |