Info

此问题已关闭。 请重新打开它进行编辑或回答。

Error in classifying variable in parallel for loop.

2 次查看(过去 30 天)
Hi! In the following code M1 is a 4d matrix. The error message I receive upon running this code is : The variable this_volume in a parfor cannot be classified. From what I understand I am just using the variable as a sliced input and output variable at the same time since I am assigning values to some of it's elements. I am not sure if the two extra for loops after the parfor are the cause of the problem. I will be grateful for any suggestions.
tic
fill_thresh = 12;
for a_fill = 1:size_M1(4)
this_volume = M1(:,:,:,a_fill);
this_volume_copy = this_volume;
parfor b_fill = 1:size_M1(3)
fill_factor = zeros(size_M1(1),size_M1(2));
for c_fill = 1+2:size_M1(1)-2
for d_fill = 1+2:size_M1(2)-2
fill_factor(c_fill,d_fill) = sum(sum(this_volume_copy(c_fill-2:c_fill+2,d_fill-2:d_fill+2,b_fill )));
if fill_factor(c_fill,d_fill ) > fill_thresh
this_volume(c_fill,d_fill,b_fill ) = 1;
end
end
end
toc
end
M1(:,:,:,a_fill) = this_volume;
toc
end

回答(1 个)

Tejas M U
Tejas M U 2014-6-16
The reason for the error is documented as - “A parfor-loop generates an error if it contains any variables that cannot be uniquely categorized or if any variables violate their category restrictions.” in the link
Here is a link that might help you figure out how to sort this out.

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by