Mercurial > hg > octave-nkf
comparison scripts/signal/spectral_adf.m @ 3426:f8dde1807dee
[project @ 2000-01-13 08:40:00 by jwe]
author | jwe |
---|---|
date | Thu, 13 Jan 2000 08:40:53 +0000 |
parents | 89405d9a9b0b |
children | 858695b3ed62 |
comparison
equal
deleted
inserted
replaced
3425:8625164a0a39 | 3426:f8dde1807dee |
---|---|
1 ## Copyright (C) 1995, 1996, 1997 Friedrich Leisch | 1 ## Copyright (C) 1995, 1996, 1997 Friedrich Leisch |
2 ## | 2 ## |
3 ## This program is free software; you can redistribute it and/or modify | 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 | 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) | 5 ## the Free Software Foundation; either version 2, or (at your option) |
6 ## any later version. | 6 ## any later version. |
7 ## | 7 ## |
8 ## This program is distributed in the hope that it will be useful, but | 8 ## This program is distributed in the hope that it will be useful, but |
9 ## WITHOUT ANY WARRANTY; without even the implied warranty of | 9 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11 ## General Public License for more details. | 11 ## General Public License for more details. |
12 ## | 12 ## |
13 ## You should have received a copy of the GNU General Public License | 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, | 14 ## along with this file. If not, write to the Free Software Foundation, |
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
16 | 16 |
17 ## usage: retval = spectral_adf (c, [win, [b]]) | 17 ## usage: retval = spectral_adf (c, [win, [b]]) |
18 ## | 18 ## |
19 ## Returns the spectral density estimator. | 19 ## Returns the spectral density estimator. |
20 ## c ....... vector of autocovariances (starting at lag 0) | 20 ## c ....... vector of autocovariances (starting at lag 0) |
21 ## win ..... window name, eg. "triangle" or "rectangle" | 21 ## win ..... window name, eg. "triangle" or "rectangle" |
22 ## spectral_adf searches for a function called win_lw () | 22 ## spectral_adf searches for a function called win_lw () |
23 ## b ....... bandwidth | 23 ## b ....... bandwidth |
24 ## | 24 ## |
25 ## If win is omitted, the triangle window is used as default. | 25 ## If win is omitted, the triangle window is used as default. |
26 ## If b is omitted, 1 / sqrt( length (c)) is used as default. | 26 ## If b is omitted, 1 / sqrt( length (c)) is used as default. |
27 | 27 |
28 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> | 28 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
29 ## Description: Spectral density estimation | 29 ## Description: Spectral density estimation |
30 | 30 |
31 function retval = spectral_adf (c, win, b) | 31 function retval = spectral_adf (c, win, b) |
32 | 32 |
33 cr = length (c); | 33 cr = length (c); |
34 | 34 |
35 if (columns (c) > 1) | 35 if (columns (c) > 1) |
36 c=c'; | 36 c=c'; |
37 endif | 37 endif |
38 | 38 |
39 if (nargin < 3) | 39 if (nargin < 3) |
44 w = triangle_lw (cr, b); | 44 w = triangle_lw (cr, b); |
45 else | 45 else |
46 win = [win, "_lw"]; | 46 win = [win, "_lw"]; |
47 w = feval (win, cr, b); | 47 w = feval (win, cr, b); |
48 endif | 48 endif |
49 | 49 |
50 c = c .* w; | 50 c = c .* w; |
51 | 51 |
52 retval = 2 * real (fft (c)) - c(1); | 52 retval = 2 * real (fft (c)) - c(1); |
53 retval = [(zeros (cr, 1)), retval]; | 53 retval = [(zeros (cr, 1)), retval]; |
54 retval(:, 1) = (0 : cr-1)' / cr; | 54 retval(:, 1) = (0 : cr-1)' / cr; |
55 | 55 |
56 endfunction | 56 endfunction |
57 | |
58 | |
59 | |
60 | 57 |
61 | 58 |
59 | |
60 | |
61 |