I have actually figure out a method to do this. I'll post it here to help anyone else out that may run into this.
I solved it by creating another matrix to store the function outputs and the indexes. Then in another loop the data can be organized. I'm open to a more elegant way of doing this though.
nlower = 2;
nupper = 4;
tlower = 3;
tupper = 7;
iterations = 6;
numOfT = tupper - tlower + 1;
numOfN = nupper - nlower + 1;
%rows are the results for each iteration
%columns are for each size of t
%layers are for each size of n
someVariable = zeros(iters, numOfT, numOfN);
VALUES = [];
for n = nlower:nupper
for t = tlower:tupper
parfor iter = 1:iterations
% someVariable(iter, (t-tlower + 1), (n - nlower + 1)) = myFunction(iter, t, n);
[val, I, T, N] = myFunction(iter, t, n);
VALUES = [VALUES; [val, iter, t, n]];
end
end
end
[lenV,~] = size(VALUES);
for i = 1:lenV
row = VALUES(i, 2);
col = VALUES(i, 3)-tlower + 1;
layer = VALUES(i, 4) - nlower + 1;
someVariable(row, col, layer) = VALUES(i,1);
end
someVariable
function [value] = myFunction(iter, t, n)
value = iter+t+n;
end