Mercurial > hg > octave-nkf
annotate scripts/signal/bartlett.m @ 15107:03381a36f70d
generate convenience libraries for new parse-tree and interpfcn subdirectories
* src/Makefile.am (liboctinterp_la_SOURCES): Include octave.cc in the
list, not $(DIST_SRC).
(liboctinterp_la_LIBADD): Include octave-value/liboctave-value.la,
parse-tree/libparse-tree.la, interp-core/libinterp-core.la,
interpfcn/libinterpfcn.la, and corefcn/libcorefcn.la in the list.
* src/interp-core/module.mk (noinst_LTLIBRARIES): Add
interp-core/libinterp-core.la to the list.
(interp_core_libinterp_core_la_SOURCES): New variable.
* src/interpfcn/module.mk (noinst_LTLIBRARIES): Add
interpfcn/libinterpfcn.la to the list.
(interpfcn_libinterpfcn_la_SOURCES): New variable.
* src/parse-tree/module.mk (noinst_LTLIBRARIES): Add
parse-tree/libparse-tree.la to the list.
(parse_tree_libparse_tree_la_SOURCES): New variable.
* src/octave-value/module.mk (noinst_LTLIBRARIES): Add
octave-value/liboctave-value.la to the list.
(octave_value_liboctave_value_la_SOURCES): New variable.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Aug 2012 09:04:30 -0400 |
parents | f3d52523cde1 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13279
diff
changeset
|
1 ## Copyright (C) 1995-2012 Andreas Weingessel |
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} {} bartlett (@var{m}) | |
21 ## Return the filter coefficients of a Bartlett (triangular) window of | |
22 ## length @var{m}. | |
3191 | 23 ## |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 ## For a definition of the Bartlett window, see e.g., A. V. Oppenheim & |
8484
895d49a7e36a
[docs] "Discrete-Time Signal Processing" => @cite{Discrete-Time Signal Processing}
Brian Gough <bjg@gnu.org>
parents:
7017
diff
changeset
|
25 ## R. W. Schafer, @cite{Discrete-Time Signal Processing}. |
3449 | 26 ## @end deftypefn |
3191 | 27 |
3457 | 28 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> |
29 ## Description: Coefficients of the Bartlett (triangular) window | |
3191 | 30 |
31 function c = bartlett (m) | |
3426 | 32 |
3191 | 33 if (nargin != 1) |
6046 | 34 print_usage (); |
3191 | 35 endif |
3426 | 36 |
13279
984359717d71
Use common code idiom for checking whether a double value is an integer.
Rik <octave@nomad.inbox5.com>
parents:
13062
diff
changeset
|
37 if (! (isscalar (m) && (m == fix (m)) && (m > 0))) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
9051
diff
changeset
|
38 error ("bartlett: M has to be an integer > 0"); |
3191 | 39 endif |
3426 | 40 |
3191 | 41 if (m == 1) |
42 c = 1; | |
43 else | |
44 m = m - 1; | |
45 n = fix (m / 2); | |
4172 | 46 c = [2*(0:n)/m, 2-2*(n+1:m)/m]'; |
3191 | 47 endif |
48 | |
49 endfunction | |
13062
b3a8b75dfec3
codesprint: 9 tests for bartlett.m
Andriy Shinkarchuck <adriano32.gnu@gmail.com>
parents:
11523
diff
changeset
|
50 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
51 |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
52 %!assert (bartlett (1), 1) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 %!assert (bartlett (2), zeros (2,1)) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %!assert (bartlett (16), fliplr (bartlett (16))) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 %!assert (bartlett (15), fliplr (bartlett (15))) |
13062
b3a8b75dfec3
codesprint: 9 tests for bartlett.m
Andriy Shinkarchuck <adriano32.gnu@gmail.com>
parents:
11523
diff
changeset
|
56 %!test |
b3a8b75dfec3
codesprint: 9 tests for bartlett.m
Andriy Shinkarchuck <adriano32.gnu@gmail.com>
parents:
11523
diff
changeset
|
57 %! N = 9; |
b3a8b75dfec3
codesprint: 9 tests for bartlett.m
Andriy Shinkarchuck <adriano32.gnu@gmail.com>
parents:
11523
diff
changeset
|
58 %! A = bartlett (N); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 %! assert (A(ceil (N/2)), 1); |
13062
b3a8b75dfec3
codesprint: 9 tests for bartlett.m
Andriy Shinkarchuck <adriano32.gnu@gmail.com>
parents:
11523
diff
changeset
|
60 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
61 %!error bartlett () |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
62 %!error bartlett (0.5) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
63 %!error bartlett (-1) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 %!error bartlett (ones (1,4)) |
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
65 |