]> Creatis software - CreaPhase.git/blob - octave_packages/tsa-4.2.4/flag_implicit_skip_nan.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / tsa-4.2.4 / flag_implicit_skip_nan.m
1 function FLAG = flag_implicit_skip_nan(i)\r
2 % FLAG_IMPLICIT_SKIP_NAN sets and gets default mode for handling NaNs
3 %       1 skips NaN's (the default mode if no mode is set)
4 %       0 NaNs are propagated; input NaN's give NaN's at the output
5\r
6 % FLAG = flag_implicit_skip_nan()\r
7 %       gets current mode
8 %
9 % flag_implicit_skip_nan(FLAG)\r    % sets mode 
10 %
11 % prevFLAG = flag_implicit_skip_nan(nextFLAG)\r
12 %       gets previous set FLAG and sets FLAG for the future
13 % flag_implicit_skip_nan(prevFLAG)\r
14 %       resets FLAG to previous mode
15 %
16 % It is used in: 
17 %       SUMSKIPNAN, MEDIAN, QUANTILES, TRIMEAN
18 % and affects many other functions like: 
19 %       CENTER, KURTOSIS, MAD, MEAN, MOMENT, RMS, SEM, SKEWNESS, 
20 %       STATISTIC, STD, VAR, ZSCORE etc. 
21 %
22 % The mode is stored in the global variable FLAG_implicit_skip_nan
23 % It is recommended to use flag_implicit_skip_nan(1) as default and
24 % flag_implicit_skip_nan(0) should be used for exceptional cases only.
25 % This feature might disappear without further notice, so you should really not
26 % rely on it. 
27
28
29 %    This program is free software; you can redistribute it and/or modify
30 %    it under the terms of the GNU General Public License as published by
31 %    the Free Software Foundation; either version 3 of the License, or
32 %    (at your option) any later version.
33 %
34 %    This program is distributed in the hope that it will be useful,
35 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
36 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37 %    GNU General Public License for more details.
38 %
39 %    You should have received a copy of the GNU General Public License
40 %    along with this program; if not, write to the Free Software
41 %    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
42
43 %       $Id: flag_implicit_skip_nan.m 8351 2011-06-24 17:35:07Z carandraug $
44 %       Copyright (C) 2001-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com>
45 %       This function is part of the NaN-toolbox
46 %       http://pub.ist.ac.at/~schloegl/matlab/NaN/
47
48
49 persistent FLAG_implicit_skip_nan;
50
51 %% if strcmp(version,'3.6'), FLAG_implicit_skip_nan=(1==1); end;        %% hack for the use with Freemat3.6
52
53 %%% set DEFAULT value of FLAG
54 if isempty(FLAG_implicit_skip_nan),
55         FLAG_implicit_skip_nan = (1==1); %logical(1); % logical.m not available on 2.0.16
56 end;
57
58 FLAG = FLAG_implicit_skip_nan;
59 if nargin>0,
60         FLAG_implicit_skip_nan = (i~=0); %logical(i); %logical.m not available in 2.0.16 
61         if (~i)
62                 warning('flag_implicit_skipnan(0): You are warned!!! You have turned off skipping NaN in sumskipnan. This is not recommended. Make sure you really know what you do.')
63         end;
64 end;
65