I'm trying to estimate the average coherence of discontinuous snippets of a signal in MATLAB. For Welch's spectrum estimates, the following works:
w = blackmanharris(50); % window n = numel(w); % fft length o = 0; % overlap x = rand(200,1); x1 = x(1:100); x2 = x(101:200); s = pwelch(x, w, o, n); s1 = pwelch(x1, w, o, n); s2 = pwelch(x2, w, o, n); sa = (s1+s2)/2; max(abs(s-sa)) % almost zero
However, when estimating coherences using Welch's method, the arithmetic mean yields an incorrect result:
y = rand(200,1); y1 = y(1:100); y2 = y(101:200); c = mscohere(x, y, w, o, n); c1 = mscohere(x1, y1, w, o, n); c2 = mscohere(x2, y2, w, o, n); ca = (c1+c2)/2; max(abs(c-ca)) % very different from zero
How can I average two coherence estimates correctly?