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

Update obsFilt function to allow a matrix of regularisation factors to be provided

parent 69d9f516
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,7 @@
% Author: Achilles Kappis
% e-mail: axilleaz@protonmail.com
%
% Date: 13/02/2025 (DD/MM/YYYY)
% Date: 14/02/2025 (DD/MM/YYYY)
%
% Copyright: MIT
% --------------------------------------------------
......@@ -31,9 +31,10 @@
% inversion of the cross-spectra of the
% monitoring microphones. Can be a vector
% with number of elements equal to K (number
% of monitoring microphones) or a scalar
% of monitoring microphones), a scalar
% which will result in the same
% regularisation factor for all microphones.
% regularisation factor for all microphones,
% or a square matrix with dimensions KxK.
% [Default: 0]
%
% snrVal [numeric] (Optional): This is the Root-Mean-Square (RMS)
......@@ -105,11 +106,15 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, Svv, regFacs, snrVal)
end
if nargin > 3 && ~isempty(regFacs)
validateattributes(regFacs, "numeric", {'vector', 'nonnegative', 'nonnan', 'nonempty', 'finite'}, mfilename, "Regularisation factors", 4);
validateattributes(regFacs, "numeric", {'2d', 'nonnan', 'nonempty', 'finite'}, mfilename, "Regularisation factors", 4);
% Make sure regFacs has correct dimensions
if ~isscalar(regFacs) && numel(regFacs) ~= size(Pm, 1)
error("Regularisation factors must be either a scalar or its length must match the number of monitoring microphones.");
if ~isscalar(regFacs)
if isvector(regFacs) && numel(regFacs) ~= size(Pm, 1)
error("If the regularisation factors are given as a vector the number of elements must match the number of monitoring microphones.");
elseif ismatrix(regFacs) && ~isequal(size(regFacs), ones(1, 2) .* size(Pm, 1))
error("If the regularisation factors are given as a matrix, it must be a square matrix with each dimension equal to the number of monitoring microphones.");
end
end
else
regFacs = 0;
......@@ -143,8 +148,10 @@ function [oOpt, Sme, Smm, condNum] = obsFilt(Pe, Pm, Svv, regFacs, snrVal)
% Regularisation matrix
if isscalar(regFacs)
regMat = eye(size(Smm)) .* regFacs;
else
elseif isvector(regFacs)
regMat = diag(regFacs);
else
regMat = regFacs;
end
% Signal-to-Noise Ratio at the monitoring microphones
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment