parfor supply error (no error with for)
古いコメントを表示
Problem:
When I run with for, everything works, when I use parfor at either the sub or the i loop level, I get a "parfor supply" error.
Description:
Input: I have a 4-dimensional dataset (15x[fixed size]x[variable size]x[variable size]).
Process: I want to perform the same functions on all of the 15 3-d elements, with four outputs each.
Output: I have tried to implement this by creating a 15x1 output cell, wherein each cell has a structure with four fields (a [2d matrix], b [3d matrix], c [3d matrix], [4d matrix]) or in the following way (4 separate matrices), without success.
load('data.mat'); %data is a 15 x 1535 x ... x ... matrix
permi=100; %number of permutations
subseti=1:5:size(data,2); %select every 5th element for extra processing
parfor sub=1:nsub
subdata=squeeze(data(sub,:,:,:)); %extract relevant 3-d data
for i=1:size(data,2)
microdata=squeeze(subdata(i,:,:)); %data for the (i)th element
a(sub,i)=foo(microdata); %process 1 on current (i)th element
b(sub,i,:)=foo2(microdata); %process 2 on current (i)th element
c(sub,i,:)=foo3(microdata); %process 2 on current (i)th element
if find(i==subseti)
for permi=1:permutei
d(sub,permi,i)=foo4(microdata);
end;
end;
end;
end;
2 件のコメント
Steven Lord
2016 年 9 月 12 日
What is the FULL text of the error you receive when you run that code? Post ALL of the red text; don't omit or paraphrase anything.
Alexandra List
2016 年 9 月 12 日
回答 (1 件)
Sean de Wolski
2016 年 9 月 12 日
My guess is that parfor is unable to determine what variables it needs due to how you called load. Instead call load with an output and grab each of the variables from it; e.g:
S = load('data.mat');
x = S.x;
y = S.y;
カテゴリ
ヘルプ センター および File Exchange で Parallel for-Loops (parfor) についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!