1 function [flag]=flag_nans_occured()
2 % FLAG_NANS_OCCURED checks whether the last call(s) to sumskipnan or covm
3 % contained any not-a-numbers in the input argument. Because many other
4 % functions like mean, std, etc. are also using sumskipnan,
5 % also these functions can be checked for NaN's in the input data.
7 % A call to FLAG_NANS_OCCURED() resets also the flag whether NaN's occured.
8 % Only sumskipnan or covm can set the flag again.
10 % see also: SUMSKIPNAN, COVM
13 % Copyright (C) 2009 by Alois Schloegl <alois.schloegl@gmail.com>
14 % This function is part of the NaN-toolbox
15 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
17 % This program is free software: you can redistribute it and/or modify
18 % it under the terms of the GNU General Public License as published by
19 % the Free Software Foundation, either version 3 of the License, or
20 % (at your option) any later version.
22 % This program is distributed in the hope that it will be useful,
23 % but WITHOUT ANY WARRANTY; without even the implied warranty of
24 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 % GNU General Public License for more details.
27 % You should have received a copy of the GNU General Public License
28 % along with this program. If not, see <http://www.gnu.org/licenses/>.
30 global FLAG_NANS_OCCURED;
32 %%% check whether FLAG was already defined
33 if isempty(FLAG_NANS_OCCURED),
34 FLAG_NANS_OCCURED = logical(0); % default value
37 flag = FLAG_NANS_OCCURED; % return value
39 FLAG_NANS_OCCURED = logical(0); % reset flag