Mercurial > octave
annotate scripts/signal/spectral_xdf.m @ 31191:bb9d776eafac stable
Fix wrong color in PDF printout of some latex strings (bug #62884)
* octave-svgconvert (draw): For "rect" elements only set brush color if
necessary and eventually restore to previous color.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Sun, 14 Aug 2022 18:24:07 +0200 |
parents | 796f54d4ddbf |
children | 5d3faba0342e |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
29359
diff
changeset
|
3 ## Copyright (C) 1995-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
3426 | 7 ## |
3922 | 8 ## This file is part of Octave. |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
3922 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
3426 | 14 ## |
3922 | 15 ## Octave is distributed in the hope that it will be useful, but |
3191 | 16 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
3426 | 19 ## |
3191 | 20 ## You should have received a copy of the GNU General Public License |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
3191 | 25 |
3449 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20231
diff
changeset
|
27 ## @deftypefn {} {} spectral_xdf (@var{x}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20231
diff
changeset
|
28 ## @deftypefnx {} {} spectral_xdf (@var{x}, @var{win}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20231
diff
changeset
|
29 ## @deftypefnx {} {} spectral_xdf (@var{x}, @var{win}, @var{b}) |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## Return the spectral density estimator given a data vector @var{x}, window |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
31 ## name @var{win}, and bandwidth, @var{b}. |
3426 | 32 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## The window name, e.g., @qcode{"triangle"} or @qcode{"rectangle"} is used to |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
34 ## search for a function called @code{@var{win}_sw}. |
3426 | 35 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
36 ## If @var{win} is omitted, the triangle window is used. |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
37 ## |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
38 ## If @var{b} is omitted, @code{1 / sqrt (length (@var{x}))} is used. |
17230
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
39 ## @seealso{spectral_adf} |
3449 | 40 ## @end deftypefn |
3426 | 41 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
42 function retval = spectral_xdf (x, win, b) |
3426 | 43 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27984
diff
changeset
|
44 if (nargin < 1) |
17230
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
45 print_usage (); |
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
46 endif |
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
47 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
48 xr = length (x); |
3426 | 49 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
50 if (columns (x) > 1) |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
51 x = x'; |
3191 | 52 endif |
3426 | 53 |
3191 | 54 if (nargin < 3) |
55 b = 1 / ceil (sqrt (xr)); | |
56 endif | |
3426 | 57 |
3191 | 58 if (nargin == 1) |
59 w = triangle_sw (xr, b); | |
17230
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
60 elseif (! ischar (win)) |
86c45a04990f
spectral_xdf.m: Add input validation, add %!tests, and fix docstring
Mike Miller <mtmiller@ieee.org>
parents:
17229
diff
changeset
|
61 error ("spectral_xdf: WIN must be a string"); |
3191 | 62 else |
17229
2736bc7bf8d9
Fix syntax error typos in spectral_adf and spectral_xdf (bug #39766)
Mike Miller <mtmiller@ieee.org>
parents:
16994
diff
changeset
|
63 win = str2func ([win "_sw"]); |
3191 | 64 w = feval (win, xr, b); |
65 endif | |
3426 | 66 |
20231
83792dd9bcc1
Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
67 x -= sum (x) / xr; |
3191 | 68 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
8920
diff
changeset
|
69 retval = (abs (fft (x)) / xr).^2; |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
70 retval = real (ifft (fft (retval) .* fft (w))); |
3426 | 71 |
3238 | 72 retval = [(zeros (xr, 1)), retval]; |
3191 | 73 retval(:, 1) = (0 : xr-1)' / xr; |
3426 | 74 |
3191 | 75 endfunction |
76 | |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
77 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
78 ## Test input validation |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
79 %!error <Invalid call> spectral_xdf () |
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
80 %!error <WIN must be a string> spectral_xdf (1, 2) |
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
28789
diff
changeset
|
81 %!error <unable to find function for @invalid_sw> spectral_xdf (1, "invalid") |