diff --git a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDmaTd.m b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDmaTd.m index 97530c4d248be57d8c4aadb020fdeb9792a34d18..f08379a58e143f4b4750d5f1fce8a29b92eb4e8d 100644 --- a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDmaTd.m +++ b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDmaTd.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 04/01/2025 (DD/MM/YYYY) +% Date: 05/01/2025 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -55,6 +55,11 @@ % separately. This is an Lx2 matrix, with L the length of the % filters. % +% cNum [numeric]: The condition number of (sMtx.' * sMtx + regFac * I) +% where "I" is an identity matrix of appropriate +% dimensions. This is to provide some indication of the +% conditioning/sensitivity of the filter. +% % out [numeric]: The output of each microphone (after filtering) for each % signal provided in the input argument "sigs". This is a % KxPx2 array, with K the length of the signals and P the @@ -71,12 +76,12 @@ % Differential Microphone Arrays" by Buchris, Cohen and Benesty. % % -------------------------------------------------- -function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) +function [hMtx, h, cNum, out, outSum] = firstOrderDmaTd(sMtx, del, regFac, sig) % ==================================================== % Check for number of arguments % ==================================================== narginchk(1, 4); - nargoutchk(0, 4); + nargoutchk(0, 5); % ==================================================== @@ -117,12 +122,12 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) % Calculate filter(s) % ==================================================== if regFac ~= 0 - hMtx = regFac * eye(size(sMtx, 2)); + invQty = regFac * eye(size(sMtx, 2)); else - hMtx = 0; + invQty = 0; end - - hMtx = (sMtx.' * sMtx + hMtx)\(sMtx.') * rhsVec; + invQty = (sMtx.' * sMtx + invQty); + hMtx = invQty\sMtx.' * rhsVec; % ==================================================== % Return additional output arguments @@ -132,8 +137,14 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) h = reshape(hMtx, [], 2); end + if nargout > 2 + cNum = cond(invQty); + else + cNum = []; + end + % Return the filtered signal(s) [output of the DMA] - if nargout > 2 && ~isempty(sig) + if nargout > 3 && ~isempty(sig) for idx = size(h, 2):-1:1 out(:, :, idx) = filter(h(:, idx), 1, sig(:, :, idx)); end @@ -141,7 +152,7 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) out = []; end - if nargout > 3 && ~isempty(out) + if nargout > 4 && ~isempty(out) outSum = squeeze(sum(out, 3)); else outSum = [];