Error when assigning table columns in parfor loop with some worker numbers
1 次查看(过去 30 天)
显示 更早的评论
I am using the latest Matlab 2020a.
The code below only works when n <= the number of workers or when n is a muptiple of the number of workers.
For example, when I set my pool worker to 12, it raises "Cannot create a table variable with a discontiguous index." error.
But it works perfectly after I set my pool worker to 7, or change n to something less than 13.
It seems that some idle workers try to fill in non-existing columns when other workers are doing the last iteration.
Does anyone have any idea about this?
n = 14;
t = table('Size', [1, n], 'VariableTypes', repmat("double", [1, n]));
parfor i = 1:n
t{:, i} = i;
end
By the way this is not a problem when filling table rows like the following example, with any n and worker number.
n = 14;
t = table('Size', [n, 2], 'VariableTypes', repmat("double", [1, 2]));
parfor i = 1:n
t{i, :} = [i, i];
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!