From f54889016b0b3f43b86222871215d56128d073c6 Mon Sep 17 00:00:00 2001
From: ZaellixA <axilleaz@protonmail.com>
Date: Fri, 13 Sep 2024 21:28:59 +0100
Subject: [PATCH] Fixed bug in input argument checks in ptSrcFieldTD.m
---
Sound Fields/MATLAB/Functions/ptSrcFieldTD.m | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m b/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m
index f470b8b..3a1ccfc 100644
--- a/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m
+++ b/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m
@@ -93,15 +93,16 @@ function [rSig, rSigMean, rSigMtx, rSigMtxMean, Q] = ptSrcFieldTD(sPos, rPos, fs
validateattributes(Q, "numeric", {'scalar', 'real', 'nonnan', 'nonempty', 'finite', 'positive', 'integer'}, mfilename, "Length of source signals in samples", 4);
else
validateattributes(Q, "numeric", {'3d', 'real', 'nonnan', 'nonempty', 'finite', 'ncols', size(sPos, 1)}, mfilename, "Source signals", 4);
- nTrials = size(Q, 3);
end
else
Q = 128;
end
- if nargin > 4 && ~isempty(nTrials) && isscalar(Q)
- validateattributes(nTrials, "numeric", {'scalar', 'positive', 'nonnan', 'nonempty', 'finite'}, mfilename, "Number of trials/sound field realisations", 5);
- elseif nargin > 4 && isempty(nTrials)
+ if ~isscalar(Q)
+ nTrials = size(Q, 3);
+ elseif nargin > 4 && ~isempty(nTrials) && isscalar(Q)
+ validateattributes(nTrials, "numeric", {'scalar', 'positive', 'nonnan', 'nonempty', 'finite'}, mfilename, "Number of trials/sound field realisations", 5);
+ else
nTrials = 1;
end
@@ -130,7 +131,7 @@ function [rSig, rSigMean, rSigMtx, rSigMtxMean, Q] = ptSrcFieldTD(sPos, rPos, fs
% Calculate signals
% ====================================================
% Go through the trials/sound field realisations
- for jIdx = size(Q, 3):-1:1
+ for jIdx = nTrials:-1:1
% Go through the sources (calculate for all receivers in one go)
for sIdx = size(dist, 1):-1:1
rSigMtx(:, :, sIdx, jIdx) = (1./dist(sIdx, :)) .* delayseq(Q(:, sIdx, jIdx), del(sIdx, :), fs);
--
GitLab