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

Update parameter list and checks in firstOrderDma.m

parent 34e5e24f
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: 17/11/2024 (DD/MM/YYYY) % Date: 04/12/2024 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -64,39 +64,44 @@ ...@@ -64,39 +64,44 @@
% Notes % Notes
% %
% -------------------------------------------------- % --------------------------------------------------
function [h, output] = firstOrderDma(input, freq, d, pPattern, beta) function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
% ==================================================== % ====================================================
% Check for number of arguments % Check for number of arguments
% ==================================================== % ====================================================
narginchk(3, 5); narginchk(2, 5);
nargoutchk(0, 2); nargoutchk(0, 2);
% ==================================================== % ====================================================
% Validate input arguments % Validate input arguments
% ==================================================== % ====================================================
validateattributes(input, {'numeric'}, {'3d', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Input', 1); validateattributes(freq, {'numeric'}, {'real', 'nonnan', 'finite', 'nonempty', 'vector'}, mfilename, 'Frequencies', 1);
validateattributes(d, {'numeric'}, {'scalar', 'real', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Inter-element distance', 2);
% Check input
if nargin > 4 && ~isempty(input)
validateattributes(input, {'numeric'}, {'3d', 'nonnan', 'finite', 'nonempty', 'size', [NaN, NaN, length(freq)]}, mfilename, 'Input', 5);
if mod(size(input, 1), 2) ~= 0 if mod(size(input, 1), 2) ~= 0
error("First dimension of 'input' parameter must have even length.") error("First dimension of 'input' parameter must have even length.")
end end
else
validateattributes(freq, {'numeric'}, {'real', 'nonnan', 'finite', 'nonempty', 'vector', 'numel', size(input, 3)}, mfilename, 'Frequencies', 2); input = [];
validateattributes(d, {'numeric'}, {'scalar', 'real', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Inter-element distance', 3); end
% Check beta % Check beta
if nargin > 4 if nargin > 3 && ~isempty(beta)
validateattributes(beta, {'numeric'}, {'scalar', 'real', 'finite', 'nonempty', 'nonnan', '<=', 1, '>=', 0}, mfilename, "Beta", 5) validateattributes(beta, {'numeric'}, {'scalar', 'real', 'finite', 'nonempty', 'nonnan', '<=', 1, '>=', 0}, mfilename, "Beta", 4)
else else
beta = 0; beta = 0;
end end
% Check alpha (angle of null) % Check alpha (angle of null)
if nargin > 3 if nargin > 2 && ~isempty(pPattern);
if isstring(pPattern) || ischar(pPattern) if isstring(pPattern) || ischar(pPattern)
validateattributes(pPattern, {'char', 'string'}, {'scalartext', 'nonempty'}, mfilename, 'Polar pattern', 4); validateattributes(pPattern, {'char', 'string'}, {'scalartext', 'nonempty'}, mfilename, 'Polar pattern', 3);
elseif isnumeric(pPattern) elseif isnumeric(pPattern)
validateattributes(pPattern, {'numeric'}, {'scalar', 'real', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Angle of null', 4); validateattributes(pPattern, {'numeric'}, {'scalar', 'real', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Angle of null', 3);
end end
else else
pPattern = "dipole"; pPattern = "dipole";
...@@ -151,7 +156,7 @@ function [h, output] = firstOrderDma(input, freq, d, pPattern, beta) ...@@ -151,7 +156,7 @@ function [h, output] = firstOrderDma(input, freq, d, pPattern, beta)
% ==================================================== % ====================================================
% Calculate array output % Calculate array output
% ==================================================== % ====================================================
if nargout > 1 if nargout > 1 && ~isempty(input)
% Go through the frequencies % Go through the frequencies
for freqIdx = length(freq):-1:1 for freqIdx = length(freq):-1:1
for pairIdx = size(input, 1)/2:-1:1 for pairIdx = size(input, 1)/2:-1:1
...@@ -159,6 +164,8 @@ function [h, output] = firstOrderDma(input, freq, d, pPattern, beta) ...@@ -159,6 +164,8 @@ function [h, output] = firstOrderDma(input, freq, d, pPattern, beta)
output(pairIdx, :, freqIdx) = h(:, freqIdx)' * input(pairIdx * 2 - 1:pairIdx * 2, :, freqIdx); output(pairIdx, :, freqIdx) = h(:, freqIdx)' * input(pairIdx * 2 - 1:pairIdx * 2, :, freqIdx);
end end
end end
else
output = [];
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment