Mercurial > hg > octave-nkf
annotate scripts/signal/spectral_adf.m @ 20305:c164cfc24bdd
QtHandles: add annotations dialog
* libgui/graphics/annotation-dialog.h: new file
* libgui/graphics/annotation-dialog.cc: new file
* libgui/graphics/annotation-dialog.ui: new file
* libgui/graphics/Canvas.cc
(canvasMousePressEvent): call annotation_dialog when in TextMode.
* libgui/graphics/module.mk: add annotation-dialog to build
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Sun, 19 Apr 2015 09:54:54 -0400 |
parents | 9fc020886ae9 |
children | f1d0f506ee78 |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 1995-2015 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 -*- |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
20 ## @deftypefn {Function File} {} spectral_adf (@var{c}) |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
21 ## @deftypefnx {Function File} {} spectral_adf (@var{c}, @var{win}) |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
22 ## @deftypefnx {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b}) |
3449 | 23 ## Return the spectral density estimator given a vector of |
24 ## autocovariances @var{c}, window name @var{win}, and bandwidth, | |
25 ## @var{b}. | |
3426 | 26 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17231
diff
changeset
|
27 ## The window name, e.g., @qcode{"triangle"} or @qcode{"rectangle"} is |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
28 ## used to search for a function called @code{@var{win}_lw}. |
3426 | 29 ## |
3449 | 30 ## If @var{win} is omitted, the triangle window is used. If @var{b} is |
31 ## omitted, @code{1 / sqrt (length (@var{x}))} is used. | |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
32 ## @seealso{spectral_xdf} |
3449 | 33 ## @end deftypefn |
3426 | 34 |
3457 | 35 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> |
36 ## Description: Spectral density estimation | |
3426 | 37 |
3191 | 38 function retval = spectral_adf (c, win, b) |
3426 | 39 |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
40 if (nargin < 1 || nargin > 3) |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
41 print_usage (); |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
42 endif |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
43 |
3191 | 44 cr = length (c); |
3426 | 45 |
3191 | 46 if (columns (c) > 1) |
8507 | 47 c = c'; |
3191 | 48 endif |
49 | |
50 if (nargin < 3) | |
51 b = 1 / ceil (sqrt (cr)); | |
52 endif | |
53 | |
54 if (nargin == 1) | |
55 w = triangle_lw (cr, b); | |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
56 elseif (! ischar (win)) |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
57 error ("spectral_adf: WIN must be a string"); |
3191 | 58 else |
17229
2736bc7bf8d9
Fix syntax error typos in spectral_adf and spectral_xdf (bug #39766)
Mike Miller <mtmiller@ieee.org>
parents:
16994
diff
changeset
|
59 win = str2func ([win "_lw"]); |
3191 | 60 w = feval (win, cr, b); |
61 endif | |
3426 | 62 |
3191 | 63 c = c .* w; |
3426 | 64 |
3191 | 65 retval = 2 * real (fft (c)) - c(1); |
3238 | 66 retval = [(zeros (cr, 1)), retval]; |
3374 | 67 retval(:, 1) = (0 : cr-1)' / cr; |
3426 | 68 |
3191 | 69 endfunction |
70 | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
71 |
20038
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
72 ## Test input validation |
17231
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
73 %!error spectral_adf (); |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
74 %!error spectral_adf (1, 2, 3, 4); |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
75 %!error spectral_adf (1, 2); |
95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
76 %!error spectral_adf (1, "invalid"); |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
77 |