# HG changeset patch # User Rik # Date 1301589266 25200 # Node ID 422a7a7e9b6ec788f95750077287f721b89ea0df # Parent 4040a95a586d0361ae16b9e914b61145f436bc37 cor.m: fix operation with only single input (bug #32961) diff -r 4040a95a586d -r 422a7a7e9b6e scripts/ChangeLog --- a/scripts/ChangeLog Thu Mar 31 07:33:11 2011 -0700 +++ b/scripts/ChangeLog Thu Mar 31 09:34:26 2011 -0700 @@ -1,6 +1,7 @@ 2011-03-31 Rik - * plot/private/__quiver__.m: Revamp autoscaling algorithm (bug #32836). + * statistics/base/cor.m: Fix operation with only single input + (bug #32961) 2011-03-29 John W. Eaton diff -r 4040a95a586d -r 422a7a7e9b6e scripts/statistics/base/cor.m --- a/scripts/statistics/base/cor.m Thu Mar 31 07:33:11 2011 -0700 +++ b/scripts/statistics/base/cor.m Thu Mar 31 09:34:26 2011 -0700 @@ -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); +