# HG changeset patch # User John W. Eaton # Date 1318043078 14400 # Node ID 007ebc128ab5ffbc7f9ba155fa2fb93088a9c8d9 # Parent 10eba5cdb5d4f6e75eb317465c698d58c1bf3998 fix input validation for sortrows * sortrows.m: Don't check values of second argument unless nargin is 2. diff --git a/scripts/general/sortrows.m b/scripts/general/sortrows.m --- a/scripts/general/sortrows.m +++ b/scripts/general/sortrows.m @@ -37,10 +37,12 @@ print_usage (); endif - if (! (isnumeric (c) && isvector (c))) - error ("sortrows: C must be a numeric vector"); - elseif (any (c == 0) || any (abs (c) > columns (A))) - error ("sortrows: all elements of C must be in the range [1, columns (A)]"); + if (nargin == 2) + if (! (isnumeric (c) && isvector (c))) + error ("sortrows: C must be a numeric vector"); + elseif (any (c == 0) || any (abs (c) > columns (A))) + error ("sortrows: all elements of C must be in the range [1, columns (A)]"); + endif endif default_mode = "ascend";