]> Creatis software - CreaPhase.git/blob - octave_packages/m/deprecated/autocor.m
update packages
[CreaPhase.git] / octave_packages / m / deprecated / autocor.m
1 ## Copyright (C) 1995-2012 Friedrich Leisch
2 ##
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {} autocor (@var{x}, @var{h})
21 ## Return the autocorrelations from lag 0 to @var{h} of vector @var{x}.
22 ## If @var{h} is omitted, all autocorrelations are computed.
23 ## If @var{x} is a matrix, the autocorrelations of each column are
24 ## computed.
25 ## The particular algorithm used is from the field of statistics and
26 ## differs from the definition used in signal processing.
27 ## @end deftypefn
28
29 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
30 ## Description: Compute autocorrelations
31
32 ## Deprecated in version 3.4
33
34 function retval = autocor (X, h)
35
36   persistent warned = false;
37   if (! warned)
38     warned = true;
39     warning ("Octave:deprecated-function",
40              "autocor is obsolete and will be removed from a future version of Octave; See the Octave-Forge signal package and the function xcor for a replacement");
41   endif
42
43
44   if (nargin == 1)
45     retval = autocov (X);
46   elseif (nargin == 2)
47     retval = autocov (X, h);
48   else
49     print_usage ();
50   endif
51
52   if (min (retval (1,:)) != 0)
53     retval = retval ./ (ones (rows (retval), 1) * retval(1,:));
54   endif
55
56 endfunction
57
58
59