1function FLAG = flag_implicit_skip_nan(i) 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% 6% FLAG = flag_implicit_skip_nan() 7% gets current mode 8% 9% flag_implicit_skip_nan(FLAG) % sets mode 10% 11% prevFLAG = flag_implicit_skip_nan(nextFLAG) 12% gets previous set FLAG and sets FLAG for the future 13% flag_implicit_skip_nan(prevFLAG) 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 45% Copyright (C) 2001-2003,2009 by Alois Schloegl <alois.schloegl@gmail.com> 46% Copyright (C) 2014-2017 Dynare Team 47% 48% This function is part of the NaN-toolbox 49% http://pub.ist.ac.at/~schloegl/matlab/NaN/ 50 51 52persistent FLAG_implicit_skip_nan; 53 54%% if strcmp(version,'3.6'), FLAG_implicit_skip_nan=(1==1); end; %% hack for the use with Freemat3.6 55 56%%% set DEFAULT value of FLAG 57if isempty(FLAG_implicit_skip_nan) 58 FLAG_implicit_skip_nan = (1==1); %logical(1); % logical.m not available on 2.0.16 59end 60 61FLAG = FLAG_implicit_skip_nan; 62if nargin>0 63 FLAG_implicit_skip_nan = (i~=0); %logical(i); %logical.m not available in 2.0.16 64 if (~i) 65 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.') 66 end 67end 68