2011-06-23 21:46:41 +02:00
|
|
|
function c = demean(x)
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2018-01-24 15:59:47 +01:00
|
|
|
% Removes the mean of each column of a matrix.
|
|
|
|
%
|
2019-12-20 16:28:06 +01:00
|
|
|
% INPUTS
|
2018-01-24 15:59:47 +01:00
|
|
|
% - x [double] T*N matrix of data.
|
|
|
|
%
|
2019-12-20 16:28:06 +01:00
|
|
|
% OUTPUTS
|
2018-01-24 15:59:47 +01:00
|
|
|
% - c [double] T*N matrix of demeaned data.
|
2011-06-23 21:46:41 +02:00
|
|
|
|
2022-04-13 13:15:19 +02:00
|
|
|
% Copyright © 2011-2018 Dynare Team
|
2017-05-16 15:10:20 +02:00
|
|
|
%
|
2011-06-23 21:46:41 +02:00
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2012-10-31 17:03:49 +01:00
|
|
|
|
2018-01-24 15:59:04 +01:00
|
|
|
if ndim(x)>2
|
|
|
|
error('This function is not implemented for arrays with dimension greater than two!')
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2018-01-24 15:59:04 +01:00
|
|
|
c = bsxfun(@minus, x, nanmean(x));
|