parfor supply error (no error with for)

6 views (last 30 days)
Alexandra List
Alexandra List on 12 Sep 2016
Edited: Walter Roberson on 12 Sep 2016
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 Comments
Steven Lord
Steven Lord on 12 Sep 2016
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.

Sign in to comment.

Answers (1)

Sean de Wolski
Sean de Wolski on 12 Sep 2016
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;

Categories

Find more on Parallel for-Loops (parfor) in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!