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 @@ ...@@ -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: 27/01/2025 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -130,7 +130,7 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input) ...@@ -130,7 +130,7 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
pPattern = pi/2; pPattern = pi/2;
beta = 0; beta = 0;
case 'cardioid' case 'cardioid'
pPattern = pi; pPattern = -pi;
beta = 0; beta = 0;
case 'hypercardioid' case 'hypercardioid'
pPattern = (2 * pi/3); pPattern = (2 * pi/3);
...@@ -146,10 +146,13 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input) ...@@ -146,10 +146,13 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
end end
% Calculate array manifolds (per frequency)
arrManMtx(:, 2, :) = arrManLoc(pPattern, d, freq, 343);
arrManMtx(:, 1, :) = arrManLoc(0, d, freq, 343);
% Calculate filter(s) % Calculate filter(s)
for freqIdx = length(freq):-1:1 for fIdx = length(freq):-1:1
arrManLocMtx = [arrManLoc(0, d, freq(freqIdx), 343), arrManLoc(pPattern, d, freq(freqIdx), 343)]; h(:, fIdx) = (arrManMtx(:, :, fIdx)')\[1; beta];
h(:, freqIdx) = (arrManLocMtx')\[1; beta];
end end
...@@ -158,10 +161,10 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input) ...@@ -158,10 +161,10 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
% ==================================================== % ====================================================
if nargout > 1 && ~isempty(input) if nargout > 1 && ~isempty(input)
% Go through the frequencies % Go through the frequencies
for freqIdx = length(freq):-1:1 for fIdx = length(freq):-1:1
for pairIdx = size(input, 1)/2:-1:1 for pairIdx = size(input, 1)/2:-1:1
% Multiply the array filter with the input % 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
end end
else else
...@@ -173,6 +176,6 @@ end ...@@ -173,6 +176,6 @@ end
%% Utility functions %% Utility functions
% Calculate the array manifold % Calculate the array manifold
function am = arrManLoc(phi, d, freq, c) 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))]; am = [exp(k * (-d/2)); exp(k * (d/2))];
end 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