Mercurial > hg > octave-nkf
diff scripts/statistics/base/cor.m @ 12555:422a7a7e9b6e
cor.m: fix operation with only single input (bug #32961)
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Thu, 31 Mar 2011 09:34:26 -0700 |
parents | fd0a3ac60b0e |
children | 4715ce9f911d |
line wrap: on
line diff
--- a/scripts/statistics/base/cor.m +++ b/scripts/statistics/base/cor.m @@ -25,7 +25,7 @@ ## @seealso{corrcoef} ## @end deftypefn -function retval = cor (x, y = []) +function retval = cor (x, y = x) if (nargin < 1 || nargin > 2) print_usage (); @@ -35,3 +35,12 @@ endfunction +%!test +%! x = rand (10, 2); +%! assert (isequal (cor (x), corrcoef (x))); +%! assert (cor (x(:,1), x(:,2)) == corrcoef (x(:,1), x(:,2))); + +%% Test input validation +%!error corrcoef (); +%!error corrcoef (1, 2, 3); +