Why does the sum not defined error happen when using mean(table col) inside a parlor loop?

2 vues (au cours des 30 derniers jours)
New to the Parallel Tool Box and confused by the results below. Can anyone explain to me why this error happens? It appears to me that the tool box doesn't support the table data type vary well, but since I'm new to this portion of MATLAB, I wanted to get other opinions.
clear all, clc
% TEST
% Nathan Kamphuis May 2014
n=10;
A = zeros(n);
b=NaN(n,1);
for i=1:n,
for j=1:n,
A(i,j)=i+j-1;
end
end
% B=A; % causes no error with line 16
B=array2table(A); % causes error with line 16
parfor i=1:n,
b(i,1)=mean(B(i,:));
% b(i,1)=mean(B{i,:}); Causes no error with either line 13 or 14
end
Analyzing and transferring files to the workers ...done.
Error using mean (line 82)
An UndefinedFunction error was thrown on the workers for 'sum'. This might be because
the file containing 'sum' is not accessible on the workers. Use addAttachedFiles(pool,
files) to specify the required files to be attached. See the documentation for
'parallel.Pool/addAttachedFiles' for more details.
Error in Mean_Test (line 15)
parfor i=1:n,
Caused by:
Undefined function 'sum' for input arguments of type 'table'.

Réponses (1)

Edric Ellis
Edric Ellis le 9 Mai 2014
I get the same error when using a FOR loop. Perhaps you're missing a call to TABLE2ARRAY? I.e.
parfor ...
b(i,1)=mean(table2array(B(i,:)));
end

Catégories

En savoir plus sur Parallel for-Loops (parfor) dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by