From ffe296b975d2c22fff7969bd34f18d97d6707dc6 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Tue, 17 Sep 2024 12:01:36 +0100 Subject: [PATCH] Fix structure of RmeMtx and RmmMtx in obsFiltTD.m --- .../MATLAB/Functions/obsFiltTD.m | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m b/Virtual Sensing/Remote Microphone Technique/MATLAB/Functions/obsFiltTD.m index 77ecd87..b0be8a2 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 -- GitLab