Mercurial > hg > octave-lojdl
changeset 17237:95a402f56b95
spectral_adf.m: Add input validation, add %!tests, and fix docstring
* spectral_adf.m: Add input validation, add %!tests, and fix docstring.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Tue, 13 Aug 2013 08:03:44 -0400 |
parents | 86c45a04990f |
children | 090145ad5b4b |
files | scripts/signal/spectral_adf.m |
diffstat | 1 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/signal/spectral_adf.m +++ b/scripts/signal/spectral_adf.m @@ -17,16 +17,19 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b}) +## @deftypefn {Function File} {} spectral_adf (@var{c}) +## @deftypefnx {Function File} {} spectral_adf (@var{c}, @var{win}) +## @deftypefnx {Function File} {} spectral_adf (@var{c}, @var{win}, @var{b}) ## Return the spectral density estimator given a vector of ## autocovariances @var{c}, window name @var{win}, and bandwidth, ## @var{b}. ## ## The window name, e.g., @code{"triangle"} or @code{"rectangle"} is -## used to search for a function called @code{@var{win}_sw}. +## used to search for a function called @code{@var{win}_lw}. ## ## If @var{win} is omitted, the triangle window is used. If @var{b} is ## omitted, @code{1 / sqrt (length (@var{x}))} is used. +## @seealso{spectral_xdf} ## @end deftypefn ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> @@ -34,6 +37,10 @@ function retval = spectral_adf (c, win, b) + if (nargin < 1 || nargin > 3) + print_usage (); + endif + cr = length (c); if (columns (c) > 1) @@ -46,6 +53,8 @@ if (nargin == 1) w = triangle_lw (cr, b); + elseif (! ischar (win)) + error ("spectral_adf: WIN must be a string"); else win = str2func ([win "_lw"]); w = feval (win, cr, b); @@ -59,7 +68,8 @@ endfunction - - - - +%% Test input validation +%!error spectral_adf (); +%!error spectral_adf (1, 2, 3, 4); +%!error spectral_adf (1, 2); +%!error spectral_adf (1, "invalid");