Skip to content
Snippets Groups Projects
Commit e0cb078e authored by Achilles Kappis's avatar Achilles Kappis
Browse files

Update the name of the firstOrderDmaTd function to match the filename and add...

Update the name of the firstOrderDmaTd function to match the filename and add a return argument with the condition of the matrix to be inverted
parent ee83b113
No related branches found
No related tags found
1 merge request!12Implementation of first order differential arrays in the time domain
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
% Author: Achilles Kappis % Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com % e-mail: axilleaz@protonmail.com
% %
% Date: 04/01/2025 (DD/MM/YYYY) % Date: 05/01/2025 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -55,6 +55,11 @@ ...@@ -55,6 +55,11 @@
% separately. This is an Lx2 matrix, with L the length of the % separately. This is an Lx2 matrix, with L the length of the
% filters. % 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 % out [numeric]: The output of each microphone (after filtering) for each
% signal provided in the input argument "sigs". This is a % signal provided in the input argument "sigs". This is a
% KxPx2 array, with K the length of the signals and P the % KxPx2 array, with K the length of the signals and P the
...@@ -71,12 +76,12 @@ ...@@ -71,12 +76,12 @@
% Differential Microphone Arrays" by Buchris, Cohen and Benesty. % 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 % Check for number of arguments
% ==================================================== % ====================================================
narginchk(1, 4); narginchk(1, 4);
nargoutchk(0, 4); nargoutchk(0, 5);
% ==================================================== % ====================================================
...@@ -117,12 +122,12 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) ...@@ -117,12 +122,12 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig)
% Calculate filter(s) % Calculate filter(s)
% ==================================================== % ====================================================
if regFac ~= 0 if regFac ~= 0
hMtx = regFac * eye(size(sMtx, 2)); invQty = regFac * eye(size(sMtx, 2));
else else
hMtx = 0; invQty = 0;
end end
invQty = (sMtx.' * sMtx + invQty);
hMtx = (sMtx.' * sMtx + hMtx)\(sMtx.') * rhsVec; hMtx = invQty\sMtx.' * rhsVec;
% ==================================================== % ====================================================
% Return additional output arguments % Return additional output arguments
...@@ -132,8 +137,14 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) ...@@ -132,8 +137,14 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig)
h = reshape(hMtx, [], 2); h = reshape(hMtx, [], 2);
end end
if nargout > 2
cNum = cond(invQty);
else
cNum = [];
end
% Return the filtered signal(s) [output of the DMA] % 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 for idx = size(h, 2):-1:1
out(:, :, idx) = filter(h(:, idx), 1, sig(:, :, idx)); out(:, :, idx) = filter(h(:, idx), 1, sig(:, :, idx));
end end
...@@ -141,7 +152,7 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig) ...@@ -141,7 +152,7 @@ function [hMtx, h, out, outSum] = firstOrderDmaTD(sMtx, del, regFac, sig)
out = []; out = [];
end end
if nargout > 3 && ~isempty(out) if nargout > 4 && ~isempty(out)
outSum = squeeze(sum(out, 3)); outSum = squeeze(sum(out, 3));
else else
outSum = []; outSum = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment