Mercurial > hg > octave-avbm
changeset 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 | 4040a95a586d |
children | 88558b8eb8a7 |
files | scripts/ChangeLog scripts/statistics/base/cor.m |
diffstat | 2 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,6 +1,7 @@ 2011-03-31 Rik <octave@nomad.inbox5.com> - * 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 <jwe@octave.org>
--- 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); +