comparison scripts/signal/autocor.m @ 3449:858695b3ed62

[project @ 2000-01-18 04:08:59 by jwe]
author jwe
date Tue, 18 Jan 2000 04:09:14 +0000
parents f8dde1807dee
children e031284eea27
comparison
equal deleted inserted replaced
3448:0fb75d95b14f 3449:858695b3ed62
12 ## 12 ##
13 ## You should have received a copy of the GNU General Public License 13 ## You should have received a copy of the GNU General Public License
14 ## along with this file. If not, write to the Free Software Foundation, 14 ## along with this file. If not, write to the Free Software Foundation,
15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 15 ## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16 16
17 ## usage: autocor (X [, h]) 17 ## -*- texinfo -*-
18 ## 18 ## @deftypefn {Function File} {} autocor (@var{x}, @var{h})
19 ## returns the autocorrelations from lag 0 to h of vector X. 19 ## Return the autocorrelations from lag 0 to @var{h} of vector @var{x}.
20 ## If h is omitted, all autocorrelations are computed. 20 ## If @var{h} is omitted, all autocorrelations are computed.
21 ## If X is a matrix, the autocorrelations of every single column are 21 ## If @var{X} is a matrix, the autocorrelations of each column are
22 ## computed. 22 ## computed.
23 ## @end deftypefn
23 24
24 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at> 25 ## Author: FL <Friedrich.Leisch@ci.tuwien.ac.at>
25 ## Description: Compute autocorrelations 26 ## Description: Compute autocorrelations
26 27
27 function retval = autocor (X, h) 28 function retval = autocor (X, h)
29 if (nargin == 1) 30 if (nargin == 1)
30 retval = autocov (X); 31 retval = autocov (X);
31 elseif (nargin == 2) 32 elseif (nargin == 2)
32 retval = autocov (X, h); 33 retval = autocov (X, h);
33 else 34 else
34 usage ("autocor (X [, h])"); 35 usage ("autocor (X, h)");
35 endif 36 endif
36 37
37 if (min (retval (1,:)) != 0) 38 if (min (retval (1,:)) != 0)
38 retval = retval ./ ( ones (rows (retval), 1) * retval(1, :) ); 39 retval = retval ./ ( ones (rows (retval), 1) * retval(1, :) );
39 endif 40 endif