Home > matlab > utilities > general > nandemean.m

nandemean

PURPOSE ^

Removes the mean of each column of a matrix with some NaNs.

SYNOPSIS ^

function c = nandemean(x)

DESCRIPTION ^

 Removes the mean of each column of a matrix with some NaNs.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function c = nandemean(x)
0002 % Removes the mean of each column of a matrix with some NaNs.
0003 
0004 %@info:
0005 %! @deftypefn {Function File} {@var{c} =} nandemean (@var{x})
0006 %! @anchor{nandemean}
0007 %! @sp 1
0008 %! This function removes the mean of each column of a matrix with some NaNs.
0009 %! @sp 2
0010 %! @strong{Inputs}
0011 %! @table @var
0012 %! @item x
0013 %! Matlab matrix (T-by-N).
0014 %! @end table
0015 %! @sp 2
0016 %! @strong{Outputs}
0017 %! @table @var
0018 %! @item c
0019 %! Matlab matrix (T-by-N). The demeaned x matrix.
0020 %! @end table
0021 %! @sp 2
0022 %! @strong{This function is called by:}
0023 %! @sp 1
0024 %! @ref{compute_cova}, @ref{compute_acov}, @ref{compute_std}
0025 %! @sp 2
0026 %! @strong{This function calls:}
0027 %! @sp 1
0028 %! @ref{ndim}
0029 %!
0030 %! @end deftypefn
0031 %@eod:
0032 
0033 % Copyright (C) 2011 Dynare Team
0034 %
0035 % This file is part of Dynare.
0036 %
0037 % Dynare is free software: you can redistribute it and/or modify
0038 % it under the terms of the GNU General Public License as published by
0039 % the Free Software Foundation, either version 3 of the License, or
0040 % (at your option) any later version.
0041 %
0042 % Dynare is distributed in the hope that it will be useful,
0043 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0044 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0045 % GNU General Public License for more details.
0046 %
0047 % You should have received a copy of the GNU General Public License
0048 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0049 
0050 % AUTHOR(S) stephane DOT adjemian AT univ DASH lemans DOT fr
0051 
0052 switch ndim(x)
0053   case 1
0054     c = x-nanmean(x);
0055   case 2
0056     c = bsxfun(@minus,x,nanmean(x));
0057   otherwise
0058     error('descriptive_statistics::nandemean:: This function is not implemented for arrays with dimension greater than two!')
0059 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005