1 ## Copyright (C) 2000-2012 Paul Kienzle
2 ## Copyright (C) 2009-2010 Jaroslav Hajek
4 ## This file is part of Octave.
6 ## Octave is free software; you can redistribute it and/or modify it
7 ## under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation; either version 3 of the License, or (at
9 ## your option) any later version.
11 ## Octave is distributed in the hope that it will be useful, but
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ## General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with Octave; see the file COPYING. If not, see
18 ## <http://www.gnu.org/licenses/>.
20 ## Validate arguments for binary set operation.
21 function [x, y] = validargs (caller, x, y, byrows_arg)
27 if (icx && ischar (y))
29 elseif (icy && ischar (x))
31 elseif (! (icx && icy))
32 error ("%s: cell array of strings cannot be combined with a nonstring value", caller);
34 elseif (! (ismatrix (x) && ismatrix (y)))
35 error ("%s: input arguments must be arrays or cell arrays of strings", caller);
38 if (strcmpi (byrows_arg, "rows"))
39 if (iscell (x) || iscell (y))
40 error ('%s: cells not supported with "rows"', caller);
41 elseif (! (ismatrix (x) && ismatrix (y)))
42 error ("%s: input arguments must be arrays or cell arrays of strings", caller);
44 if (ndims (x) > 2 || ndims (y) > 2)
45 error ('%s: need 2-dimensional matrices for "rows"', caller);
46 elseif (columns (x) != columns (y) && ! (isempty (x) || isempty (y)))
47 error ("%s: number of columns must match", caller);
51 error ("%s: invalid option: %s", caller, byrows_arg);