Why does the parfor Classification Error happen using a partial row from a table, but not the full row?
Ältere Kommentare anzeigen
Here is a simplified script of an activity that is much more complicated. I'm trying to slice a row of C but only set some of its values. Having to write clunky syntax that wastes memory doesn't seem very desirable. If thats the way it works, so be it.
clear all; clc;
% TEST for classifcation in a parfor loop
% Nathan Kamphuis May 2014
n=10;
% C=array2table(NaN(n,3)); % No Error with line 14
C=array2table(NaN(n,5)); % Error with line 15
parfor i=1:n,
A = zeros(1,n);
for j=1:n,
A(1,j)=i+j-1;
end
B=array2table(A);
% C(i,:)=B(1,[2 4 5]);
C(i,2:4)=B(1,[2 4 5]);
end
Error using Classifacation_Test (line 8)
Error: The variable C in a parfor cannot be classified.
See Parallel for Loops in MATLAB, "Overview".
Here is a workable solution to the problem of getting the code to run. I'm hoping someone can explain to me why the classifier portion of the parallel tool box is not "smart" enough to realize that I'm trying to slice a single row of Table C to work on a portion of it.
clear all; clc;
% TEST for classifcation in a parfor loop
% Nathan Kamphuis May 2014
n=10;
% C=array2table(NaN(n,3)); % No Error with line 14
C=array2table(NaN(n,5)); % Error with line 15
parfor i=1:n,
A = zeros(1,n);
for j=1:n,
A(1,j)=i+j-1;
end
B=array2table(A);
% C(i,:)=B(1,[2 4 5]);
% C(i,2:4)=B(1,[2 4 5]);
% C(i,:)=[C(i,1), B(1,[2 4 5]), C(i,5:end)];
% C(i,2:4)=array2table(B{1,[2 4 5]});
D=C(i,:);
% D(1,:)=array2table([D{1,1}, B{1,[2 4 5]}, D{1,5:end}]);
D(1,:)=[D(1,1), B(1,[2 4 5]), D(1,5:end)];
C(i,:)=D;
end
This Code shows that the problem is not limited to the table data type but is also for numeric arrays as well.
clear all; clc;
% TEST for classifcation in a parfor loop
% Nathan Kamphuis May 2014
n=10;
C =NaN(n,5);
parfor i=1:n,
A = zeros(1,n);
for j=1:n,
A(1,j)=i+j-1;
end
C(i,2:4)=B(1,[2 4 5]);
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Parallel Computing Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!