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 @@
% 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 = [];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment