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

Vectorise calculation of array manifolds

parent 1a21124f
Branches
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
% Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com
%
% Date: 04/01/2025 (DD/MM/YYYY)
% Date: 27/01/2025 (DD/MM/YYYY)
%
% Copyright: MIT
% --------------------------------------------------
......@@ -130,7 +130,7 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
pPattern = pi/2;
beta = 0;
case 'cardioid'
pPattern = pi;
pPattern = -pi;
beta = 0;
case 'hypercardioid'
pPattern = (2 * pi/3);
......@@ -146,10 +146,13 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
end
% Calculate array manifolds (per frequency)
arrManMtx(:, 2, :) = arrManLoc(pPattern, d, freq, 343);
arrManMtx(:, 1, :) = arrManLoc(0, d, freq, 343);
% Calculate filter(s)
for freqIdx = length(freq):-1:1
arrManLocMtx = [arrManLoc(0, d, freq(freqIdx), 343), arrManLoc(pPattern, d, freq(freqIdx), 343)];
h(:, freqIdx) = (arrManLocMtx')\[1; beta];
for fIdx = length(freq):-1:1
h(:, fIdx) = (arrManMtx(:, :, fIdx)')\[1; beta];
end
......@@ -158,10 +161,10 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
% ====================================================
if nargout > 1 && ~isempty(input)
% Go through the frequencies
for freqIdx = length(freq):-1:1
for fIdx = length(freq):-1:1
for pairIdx = size(input, 1)/2:-1:1
% Multiply the array filter with the input
output(pairIdx, :, freqIdx) = h(:, freqIdx)' * input(pairIdx * 2 - 1:pairIdx * 2, :, freqIdx);
output(pairIdx, :, fIdx) = h(:, fIdx)' * input(pairIdx * 2 - 1:pairIdx * 2, :, fIdx);
end
end
else
......@@ -173,6 +176,6 @@ end
%% Utility functions
% Calculate the array manifold
function am = arrManLoc(phi, d, freq, c)
k = -2j * pi * freq * cos(phi)/c;
k = -2j * pi * freq * cos(phi)/c; k = k(:).';
am = [exp(k * (-d/2)); exp(k * (d/2))];
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment