Hello,
I understand you are facing an issue when trying to obtain the mean of a transformed tall array through the 2 different methods “matlab.tall.reduce” and “matlab.tall.transform”.
The “matlab.tall.reduce” function performs a reduction operation on the tall array by dividing it into partitions and applying the reduction function to each partition. The partial results are then combined using the “mean” function in your case until a single result is obtained.
On the other hand, when you use “matlab.tall.transform” followed by gather and mean, you're applying the custom function to the entire tall array, gathering the results into memory, and then calculating the mean.
You can use the following code example to obtain the same results for mean when using “matlab.tall.reduce”.
% Change reduce function to output the sum across dim 1 - Once partial
% outputs are reduced we will obtain total sum and total number of elements
% in a 2x1 matrix
reducefcn = @(x) sum(x,1);
myOutput1 = matlab.tall.reduce(@sumcount, reducefcn, signal, time);
myOutput1Gathered = gather(myOutput1);
% Calculating Mean
myOutput1Mean = myOutput1Gathered(1)/myOutput1Gathered(2);
% Create Partial output containing sum and num of elements
function out = sumcount(signal,time)
out = [sum(CustomFunction(signal,time)) numel(signal)];
end
I Hope this helps.