autocov is initialized NaN with the original order and then only loop up to updted order compatible with sample size.

time-shift
Marco Ratto 2021-02-13 11:27:18 +01:00
parent 15ab85788c
commit d56bba724c
1 changed files with 2 additions and 1 deletions

View File

@ -55,8 +55,9 @@ function autocov = nanautocovariance(data,order)
n = size(data,2);
missing = isanynan(data);
autocov = nan(n, n, order);
order = min(size(data,1)-2,order);
autocov = zeros(n, n, order);
autocov(:, :, 1:order)=0;
for lag=1:order
if missing