diff --git a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m index b7b04409e548dd779b6acea0cf2bcfa9e028825e..7d03383c2718f788c3cdb336d5fd0a9acb3f450f 100644 --- a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m +++ b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m @@ -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