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

Change an input variable name and make sure that the warnings status will be...

Change an input variable name and make sure that the warnings status will be reset even if calculations fail
parent 87e3cbe5
Branches
No related tags found
1 merge request!10Update 3D rotations function interface
...@@ -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: 21/10/2024 (DD/MM/YYYY) % Date: 02/11/2024 (DD/MM/YYYY)
% %
% Copyright: MIT % Copyright: MIT
% -------------------------------------------------- % --------------------------------------------------
...@@ -25,8 +25,10 @@ ...@@ -25,8 +25,10 @@
% pointing towards the incoming plane waves and not towards % pointing towards the incoming plane waves and not towards
% the array/origin. % the array/origin.
% %
% nRows [numeric]: The number of rows in the final "array manifold" matrix % filtLen [numeric]: This argument represents the length of the DMA filter
% for each direction (see notes). % if this function is used in the context of time-domain
% DMA filter design. In general, defines the number of
% rows the output array will have per direction.
% %
% delLen [numeric] (Optional): The length of the (fractional) delay % delLen [numeric] (Optional): The length of the (fractional) delay
% filters used to calculate the "array % filters used to calculate the "array
...@@ -62,25 +64,22 @@ ...@@ -62,25 +64,22 @@
% -------------------------------------------------- % --------------------------------------------------
% Output % Output
% %
% am [numeric]: This is an LxKxMxN array, where L is equal to "nRows", K % am [numeric]: This is an LxKxMxN array, where L is equal to "filtLen", K
% is equal to nRows + delLen + ceil(2 * max(abs(del))) where % is equal to filtLen + delLen + ceil(2 * max(abs(del)))
% "del" is the delay between the sensors and the centre of % where "del" is the delay between the sensors and the centre
% mass of the array. M is the number of sensors and N is the % of mass of the array. M is the number of sensors and N is
% number of directions. % the number of directions.
% %
% maxDel [numeric]: The maximum delay from the centre of mass to the % maxDel [numeric]: The maximum delay from the centre of mass to the
% sensors. % sensors.
% %
% amMtx [numeric]: This is an LMxKxN array, where LM is equal to L * M. % amMtx [numeric]: This is an LMxKxN array, where LM is equal to L * M.
% This corresponds to the vectorised version of "am" with % This corresponds to the "vectorised" version of "am"
% the "am" of each sensor stacked under each other. % with the "am" of each sensor stacked under each other.
% %
% -------------------------------------------------- % --------------------------------------------------
% Notes % Notes
% %
% - The "nRows" argument represents the length of the DMA filter if this
% function is used in the context of time-domain DMA filter design.
%
% - The point of reference for the array is its centre of mass and it is % - The point of reference for the array is its centre of mass and it is
% calculated internally with dimensions equal to the mean of each % calculated internally with dimensions equal to the mean of each
% dimension over all the sensor positions. % dimension over all the sensor positions.
...@@ -92,7 +91,7 @@ ...@@ -92,7 +91,7 @@
% - Dependencies: * winSincFracDel() to calculate the fractional delay % - Dependencies: * winSincFracDel() to calculate the fractional delay
% filters. % filters.
% -------------------------------------------------- % --------------------------------------------------
function [am, maxDel, amMtx] = arrManTD(mPos, dirs, nRows, delLen, delWin, fs, c) function [am, maxDel, amMtx] = arrManTD(mPos, dirs, filtLen, delLen, delWin, fs, c)
% ==================================================== % ====================================================
% Check for number of arguments % Check for number of arguments
% ==================================================== % ====================================================
...@@ -105,7 +104,7 @@ function [am, maxDel, amMtx] = arrManTD(mPos, dirs, nRows, delLen, delWin, fs, c ...@@ -105,7 +104,7 @@ function [am, maxDel, amMtx] = arrManTD(mPos, dirs, nRows, delLen, delWin, fs, c
% Validate mandatory arguments % Validate mandatory arguments
validateattributes(mPos, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 3}, mfilename, "Position of sensors", 1); validateattributes(mPos, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 3}, mfilename, "Position of sensors", 1);
validateattributes(dirs, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 2}, mfilename, "Directions of interest", 2); validateattributes(dirs, "numeric", {'2d', 'finite', 'nonnan', 'nonempty', 'real', 'nrows', 2}, mfilename, "Directions of interest", 2);
validateattributes(nRows, "numeric", {'scalar', 'finite', 'nonnan', 'nonempty', 'positive', 'real'}, mfilename, "Number of rows of the 'array manifold'", 3); validateattributes(filtLen, "numeric", {'scalar', 'finite', 'nonnan', 'nonempty', 'positive', 'real'}, mfilename, "Number of rows of the 'array manifold'", 3);
% Optional arguments % Optional arguments
if nargin > 3 && ~isempty(delLen) if nargin > 3 && ~isempty(delLen)
...@@ -158,12 +157,22 @@ function [am, maxDel, amMtx] = arrManTD(mPos, dirs, nRows, delLen, delWin, fs, c ...@@ -158,12 +157,22 @@ function [am, maxDel, amMtx] = arrManTD(mPos, dirs, nRows, delLen, delWin, fs, c
% ============================================= % =============================================
% Form Sylvester matrices % Form Sylvester matrices
% ============================================= % =============================================
% Turn warnings about the generation of Toeplitz matrices off
w = warning("off", "MATLAB:toeplitz:DiagonalConflict"); w = warning("off", "MATLAB:toeplitz:DiagonalConflict");
try
% Generate Sylvester matrices for each mic and angle
for angIdx = size(h, 3):-1:1 for angIdx = size(h, 3):-1:1
for mIdx = size(h, 2):-1:1 for mIdx = size(h, 2):-1:1
am(:, :, mIdx, angIdx) = toeplitz([h(:, mIdx, angIdx); zeros(nRows - 1, 1)], zeros(nRows, 1)).'; am(:, :, mIdx, angIdx) = toeplitz([h(:, mIdx, angIdx); zeros(filtLen - 1, 1)], zeros(filtLen, 1)).';
end end
end end
catch
% Make sure to turn the warnings on again if an error occurs
warning(w.state, w.identifier);
end
% Reset the warnings state
warning(w.state, w.identifier); warning(w.state, w.identifier);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment