1 ## Copyright (C) 2005 Michel D. Schmid <michaelschmid@users.sourceforge.net>
4 ## This program is free software; you can redistribute it and/or modify it
5 ## under the terms of the GNU General Public License as published by
6 ## the Free Software Foundation; either version 2, or (at your option)
9 ## This program is distributed in the hope that it will be useful, but
10 ## WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ## General Public License for more details.
14 ## You should have received a copy of the GNU General Public License
15 ## along with this program; see the file COPYING. If not, see
16 ## <http://www.gnu.org/licenses/>.
19 ## @deftypefn {Function File} {} @var{Pr} = min_max (@var{Pp})
20 ## @code{min_max} returns variable Pr with range of matrix rows
23 ## PR - R x 2 matrix of min and max values for R input elements
27 ## Pp = [1 2 3; -1 -0.5 -3]
29 ## pr = [1 3; -0.5 -3];
33 ## Author: Michel D. Schmid
35 function Pr = min_max(Pp)
37 ## check number of input args
38 error(nargchk(1,1,nargin))
40 Pr = []; # returns an empty matrix
42 if (!(size(Pp,1)==1) && !(size(Pp,2)==1)) # ismatrix(1) will return 1!!!
43 if isreal(Pp) # be sure, this is no complex matrix
44 Pr = [min(Pp,[],2) max(Pp,[],2)];
46 error("Argument has illegal type.")
49 error("Argument must be a matrix.")
55 %! disp("testing min_max")
56 %!test fail("min_max(1)","Argument must be a matrix.")
57 %!test fail("min_max('testString')","Argument must be a matrix.")
58 %!test fail("min_max(cellA{1}=1)","Argument must be a matrix.")
59 %!test fail("min_max([1+1i, 2+2i])","Argument must be a matrix.")
60 %!test fail("min_max([1+1i, 2+2i; 3+1i, 4+2i])","Argument has illegal type.")