Mercurial > hg > octave-lyh
annotate scripts/signal/spectral_adf.m @ 11540:b0ef6f28e09a
deprecate krylovb function
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 15 Jan 2011 03:40:32 -0500 |
parents | fd0a3ac60b0e |
children | 72c96de7a403 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 1995-2011 Friedrich Leisch |
3426 | 2 ## |
3922 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
3426 | 9 ## |
3922 | 10 ## Octave is distributed in the hope that it will be useful, but |
3191 | 11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3426 | 13 ## General Public License for more details. |
14 ## | |
3191 | 15 ## You should have received a copy of the GNU General Public License |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
3191 | 18 |
3449 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b}) | |
21 ## Return the spectral density estimator given a vector of | |
22 ## autocovariances @var{c}, window name @var{win}, and bandwidth, | |
23 ## @var{b}. | |
3426 | 24 ## |
3449 | 25 ## The window name, e.g., @code{"triangle"} or @code{"rectangle"} is |
26 ## used to search for a function called @code{@var{win}_sw}. | |
3426 | 27 ## |
3449 | 28 ## If @var{win} is omitted, the triangle window is used. If @var{b} is |
29 ## omitted, @code{1 / sqrt (length (@var{x}))} is used. | |
30 ## @end deftypefn | |
3426 | 31 |
3457 | 32 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
33 ## Description: Spectral density estimation | |
3426 | 34 |
3191 | 35 function retval = spectral_adf (c, win, b) |
3426 | 36 |
3191 | 37 cr = length (c); |
3426 | 38 |
3191 | 39 if (columns (c) > 1) |
8507 | 40 c = c'; |
3191 | 41 endif |
42 | |
43 if (nargin < 3) | |
44 b = 1 / ceil (sqrt (cr)); | |
45 endif | |
46 | |
47 if (nargin == 1) | |
48 w = triangle_lw (cr, b); | |
49 else | |
7540
3422f39573b1
strcat.m: Matlab compatibility, with cstrcat.m replacing conventional strcat.m.
Ben Abbott <bpabbott@mac.com>
parents:
7017
diff
changeset
|
50 win = str2func (cstrcat (win, "_lw")); |
3191 | 51 w = feval (win, cr, b); |
52 endif | |
3426 | 53 |
3191 | 54 c = c .* w; |
3426 | 55 |
3191 | 56 retval = 2 * real (fft (c)) - c(1); |
3238 | 57 retval = [(zeros (cr, 1)), retval]; |
3374 | 58 retval(:, 1) = (0 : cr-1)' / cr; |
3426 | 59 |
3191 | 60 endfunction |
61 | |
62 | |
3426 | 63 |
64 | |
65 |