Home > chronux_1_50 > spikesort > minmax.m

minmax

PURPOSE ^

MINMAX Simultaneous overall smallest and largest components.

SYNOPSIS ^

function [extrema,inds] = minmax(X)

DESCRIPTION ^

MINMAX            Simultaneous overall smallest and largest components.
   Y = MINMAX(X) returns the minimum and maximum values, of the array X
   such that Y(1) = MIN(X) and Y(2) = MAX(X).  For N-D arrays X,
   MINMAX(X) is equivalent to MINMAX(X(:)).

   [Y,I] = MINMAX(X) also returns the linear indices of the extrema such
   that, Y(1) == X(I(1)) and Y(2) == X(I(2)).  When X has more than one
   extremal element, the index of the first is returned.

   X must be a real, double array.  +/- Inf values behave as greater/less
   than all other finite values, respectively.  NaN's are ignored. 
 
   The algorithm is significantly faster than sequentially calling
   Matlab's min/max.  However, an already sorted input and/or a large
   proportion of NaN values can decrease this advantage.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [extrema,inds] = minmax(X)
0002 %MINMAX            Simultaneous overall smallest and largest components.
0003 %   Y = MINMAX(X) returns the minimum and maximum values, of the array X
0004 %   such that Y(1) = MIN(X) and Y(2) = MAX(X).  For N-D arrays X,
0005 %   MINMAX(X) is equivalent to MINMAX(X(:)).
0006 %
0007 %   [Y,I] = MINMAX(X) also returns the linear indices of the extrema such
0008 %   that, Y(1) == X(I(1)) and Y(2) == X(I(2)).  When X has more than one
0009 %   extremal element, the index of the first is returned.
0010 %
0011 %   X must be a real, double array.  +/- Inf values behave as greater/less
0012 %   than all other finite values, respectively.  NaN's are ignored.
0013 %
0014 %   The algorithm is significantly faster than sequentially calling
0015 %   Matlab's min/max.  However, an already sorted input and/or a large
0016 %   proportion of NaN values can decrease this advantage.
0017 
0018 %%%%% Argument checking.
0019 if (~strcmp(class(X), 'double') || ~isreal(X)), 
0020     error('X must be a real, double array.');  
0021 end;
0022 
0023 [extrema(1),extrema(2),inds(1),inds(2)] = CORE_minmax(X(:));
0024

Generated on Mon 09-Oct-2006 00:54:52 by m2html © 2003