1 function [Y,Z] = nanfilter(B,A,X,z);
2 % NANFILTER is able to filter data with missing values encoded as NaN.
4 % [Y,Z] = nanfilter(B,A,X [, Z]);
6 % If X contains no missing data, NANFILTER should behave like FILTER.
7 % NaN-values are handled gracefully.
9 % WARNING: missing values can introduce aliasing - causing unintended results.
10 % Moreover, the behavior of bandpass and highpass filters in case of missing values
11 % is not fully understood, and might contain some pitfalls.
13 % see also: FILTER, SUMSKIPNAN, NANFFT, NANCONV, NANFILTER1UC
16 % Copyright (C) 2005,2011 by Alois Schloegl <alois.schloegl@gmail.com>
17 % This function is part of the NaN-toolbox available at
18 % http://pub.ist.ac.at/~schloegl/matlab/NaN/ and
19 % http://octave.svn.sourceforge.net/viewvc/octave/trunk/octave-forge/extra/NaN/inst/
21 % This program is free software; you can redistribute it and/or modify
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, write to the Free Software
33 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36 warning('NANFILTER is experimental. For more details see HELP NANFILTER');
47 [t,Z.S] = filter(B,A,zeros(na+nb,nc));
48 [t,Z.N] = filter(B,A,zeros(na+nb,nc));
51 [t, Z.N] = filter(B, A, zeros(na+nb,nc));
59 [Y , Z.S] = filter(B, A, X, Z.S);
60 [NY, Z.N] = filter(B, A, ~NX, Z.N);
61 Y = (sum(B)/sum(A)) * Y./NY;