diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m index 77ecd8770ab075a325f4e3b7291ba51b5a1a191b..b0be8a2c93ee53869b211a3d8634e6ab9f63a302 100644 --- a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m +++ b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m @@ -211,27 +211,24 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM for mIdx = size(m, 2):-1:1 % Calculate the cross-correlations between virtual and monitoring microphones for eIdx = size(e, 2):-1:1 - [corr, lags] = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx)); - lIdx = find(lags == 0); + corr = xcorr(m(:, mIdx, jIdx), e(:, eIdx, jIdx), filtLen, "unbiased"); - Rme(:, mIdx, eIdx, jIdx) = corr(lIdx:-1:lIdx-filtLen + 1); + Rme(:, mIdx, eIdx, jIdx) = corr(filtLen + 1:-1:2); end % Go through the monitoring microphones to calculate the monitoring microphone correlation matrices for mmIdx = mIdx:-1:1 % Auto-correlation matrices are Toeplitz symmetric if mIdx == mmIdx - [corr, lags] = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx)); - lIdx = find(lags == 0); + corr = xcorr(m(:, mmIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased"); - Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(lIdx:-1:lIdx - filtLen + 1)); + Rmm(:, :, mIdx, mmIdx, jIdx) = toeplitz(corr(filtLen + 1:-1:2)); else - [corr, lags] = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx)); - lIdx = find(lags == 0); + corr = xcorr(m(:, mIdx, jIdx), m(:, mmIdx, jIdx), filtLen, "unbiased"); % Cross-correlation matrices for iIdx = filtLen-1:-1:0 - Rmm(:, iIdx + 1, mIdx, mmIdx, jIdx) = corr(iIdx + (lIdx:-1:lIdx - filtLen + 1)); + Rmm(:, iIdx + 1, mIdx, mmIdx, jIdx) = corr(iIdx + (filtLen + 1:-1:2)); end Rmm(:, :, mmIdx, mIdx, jIdx) = squeeze(Rmm(:, :, mIdx, mmIdx, jIdx)).'; end @@ -243,8 +240,8 @@ function [O, Rme, Rmm, Ovec, RmeMtx, RmmMtx, condNum, mMtx, Omean, RmeMean, RmmM % Post-process cross- and auto-correlation matrices % ==================================================== % "Reshape" the data - RmeMtx = reshape(Rme, prod(size(Rme, [1, 2])), size(Rme, 3), size(Rme, 4)); - RmmMtx = reshape(permute(Rmm, [1, 3, 2, 4, 5]), prod(size(Rmm, [1, 3])), prod(size(Rmm, [2, 4])), size(Rmm, 5)); + RmeMtx = reshape(permute(Rme, [2, 1, 3, 4]), prod(size(Rme, [1, 2])), size(Rme, 3), size(Rme, 4)); + RmmMtx = reshape(permute(Rmm, [3, 1, 4, 2, 5]), prod(size(Rmm, [1, 3])), prod(size(Rmm, [2, 4])), size(Rmm, 5)); % ==================================================== % Calculate observation filters