1 function Q=range(Y,DIM)
2 % RANGE calculates the range of Y
3 % Missing values (encoded as NaN) are ignored.
7 % returns the range along dimension DIM of sample array Y.
10 % returns the RANGE from the histogram HIS.
11 % HIS must be a HISTOGRAM struct as defined in HISTO2 or HISTO3.
13 % see also: IQR, MAD, HISTO2, HISTO3, PERCENTILE, QUANTILE
17 % Copyright (C) 2009,2010,2011 by Alois Schloegl <alois.schloegl@gmail.com>
18 % This function is part of the NaN-toolbox
19 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
22 % it under the terms of the GNU General Public License as published by
23 % the Free Software Foundation; either version 3 of the License, or
24 % (at your option) any later version.
26 % This program is distributed in the hope that it will be useful,
27 % but WITHOUT ANY WARRANTY; without even the implied warranty of
28 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 % GNU General Public License for more details.
31 % You should have received a copy of the GNU General Public License
32 % along with this program; If not, see <http://www.gnu.org/licenses/>.
38 DIM = find(size(Y)>1,1);
39 if isempty(DIM), DIM = 1; end;
48 if SW, SW = isfield(Y,'datatype'); end;
49 if SW, SW = strcmp(Y.datatype,'HISTOGRAM'); end;
51 Q = repmat(NaN,1,size(Y.H,2));
53 t = Y.X(find(Y.H(:,k)>0),min(size(Y.X,2),k));
54 Q(1,k) = max(t)-min(t);
56 elseif isnumeric(Y) && nargin==1,
58 elseif isnumeric(Y) && nargin==2,
59 Q = max(Y,[],DIM) - min(Y,[],DIM);