基本構造が以下のコードがあります。for ループの反復が多いため、for ループを parfor ループに変換することを考えていました。残念ながら、エラーが発生しています: The repmorary variable 'DeclaredVar' uses a value set outside the PARFOR
。このような問題を克服するためのテクニックはありますか?
t = ee; % save my data in t. t is a Nx1 vector
boolvar = 0;
parfor x=1:length(xs) % xs is a Mx1 vector (N>>M).
xx = xs(x);
t = t(t>=xx); %% the temporary variable 't' uses a value set outside the PARFOR loop
if boolvar==0 %% the temporary variable 'boolvar' uses a value set outside the PARFOR loop
try
% Part 1 code
catch
boolvar = 1;
end;
end;
if boolvar==1
% execute Part 2 code if boolvar is true
end;
M(x,:) = % save data. M is a length(xs) x 2 matrix
end
ありがとうございました!