【发布时间】:2016-10-29 03:52:08
【问题描述】:
全部,
我在 matlab 上运行 parfor 时遇到了一个非常有趣的情况,以下是我的问题。
fid = 'test.nc';
temp = ncread(fid,'temp');
[s1,s2,s3] = size(temp);
for m = 1 : 100
parfor xid = 1 : s1
for yid = 1 : s2
output = struct;
output.t = squeeze(temp(xid,yid,:));
if ~isnan(temp(xid,yid,37))
output.t(:) = 1;
else
output.t(:) = nan;
end
temp(xid,yid,:) = output.t;
end
end
end
在这种情况下,我收到了错误消息...
“使用 pwp_parallel 时出错(第 238 行)错误:无法对 parfor 中的变量 temp 进行分类。请参阅 MATLAB 中的并行 for 循环,“概述”。”
但是,如果我的代码看起来像这样......
fid = 'test.nc';
temp = ncread(fid,'temp');
[s1,s2,s3] = size(temp);
for m = 1 : 100
parfor xid = 1 : s1
for yid = 1 : s2
output = struct;
output.t = squeeze(temp(xid,yid,:));
output.t(:) = 1;
temp(xid,yid,:) = output.t;
end
end
end
代码正在运行。
有人可以帮我处理这个错误吗?
【问题讨论】: