From 145f1e7b1cc71281bf9c32e5c4a1f092c000755d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Adjemian=20=28Charybdis=29?= Date: Wed, 24 Jan 2018 15:59:04 +0100 Subject: [PATCH] Streamlined code by removing unnecessary conditions. --- matlab/utilities/general/demean.m | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/matlab/utilities/general/demean.m b/matlab/utilities/general/demean.m index b9dda8d13..dffd31444 100644 --- a/matlab/utilities/general/demean.m +++ b/matlab/utilities/general/demean.m @@ -44,12 +44,8 @@ function c = demean(x) % You should have received a copy of the GNU General Public License % along with Dynare. If not, see . -% Original author: stephane DOT adjemian AT univ DASH lemans DOT fr +if ndim(x)>2 + error('This function is not implemented for arrays with dimension greater than two!') +end -if ndim(x)==1 - c = x-nanmean(x); -elseif ndim(x)==2 - c = bsxfun(@minus,x,nanmean(x)); -else - error('descriptive_statistics::demean:: This function is not implemented for arrays with dimension greater than two!') -end \ No newline at end of file +c = bsxfun(@minus, x, nanmean(x)); \ No newline at end of file