diff --git a/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m b/Sound Fields/MATLAB/Functions/ptSrcFieldTD.m
index f470b8bcad3cddc169ab702fc35ecbf6b4dfcd72..3a1ccfce887ad7e4ea8d74193649143ec26ef2b9 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);