我有一个代码,其基本结构如下。因为有很多 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
谢谢!