From 4617963655c47b3858bdd885688c7a909eceb1b1 Mon Sep 17 00:00:00 2001
From: Johannes Pfeifer <jpfeifer@gmx.de>
Date: Sat, 20 Jan 2018 08:26:00 +0100
Subject: [PATCH] Make demean.m use nanmean

Otherwise estimation with missing observations and prefilter option will crash

(cherry picked from commit 92549e48b12c60165693f9ea1289825e88b35cdd)
---
 matlab/utilities/general/demean.m | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/matlab/utilities/general/demean.m b/matlab/utilities/general/demean.m
index 741a2f107..b9dda8d13 100644
--- a/matlab/utilities/general/demean.m
+++ b/matlab/utilities/general/demean.m
@@ -47,9 +47,9 @@ function c = demean(x)
 % Original author: stephane DOT adjemian AT univ DASH lemans DOT fr
 
 if ndim(x)==1
-    c = x-mean(x);
+    c = x-nanmean(x);
 elseif ndim(x)==2
-    c = bsxfun(@minus,x,mean(x));
+    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
-- 
GitLab