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
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
Alexandra List 2016년 9월 12일
script.m>(parfor supply)

댓글을 달려면 로그인하십시오.

답변 (1개)

Sean de Wolski
Sean de Wolski 2016년 9월 12일

0 개 추천

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)에 대해 자세히 알아보기

질문:

2016년 9월 12일

편집:

2016년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by