1 ## Copyright (C) 2001 Paul Kienzle <pkienzle@users.sf.net>
2 ## Copyright (C) 2003 Alois Schloegl <alois.schloegl@ist.ac.at>
4 ## This program is free software; you can redistribute it and/or modify it under
5 ## the terms of the GNU General Public License as published by the Free Software
6 ## Foundation; either version 3 of the License, or (at your option) any later
9 ## This program is distributed in the hope that it will be useful, but WITHOUT
10 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 ## You should have received a copy of the GNU General Public License along with
15 ## this program; if not, see <http://www.gnu.org/licenses/>.
18 ## @deftypefn {Function File} {[@var{v}, @var{idx}] =} nanmin (@var{X})
19 ## @deftypefnx{Function File} {[@var{v}, @var{idx}] =} nanmin (@var{X}, @var{Y})
20 ## Find the minimal element while ignoring NaN values.
22 ## @code{nanmin} is identical to the @code{min} function except that NaN values
23 ## are ignored. If all values in a column are NaN, the minimum is
24 ## returned as NaN rather than [].
26 ## @seealso{min, nansum, nanmax, nanmean, nanmedian}
29 function [v, idx] = nanmin (X, Y, DIM)
30 if nargin < 1 || nargin > 3
32 elseif nargin == 1 || (nargin == 2 && isempty(Y))
36 v(all(nanvals)) = NaN;
37 elseif (nargin == 3 && isempty(Y))
41 v(all(nanvals,DIM)) = NaN;