I get an error, what's wrong?

parfor m = 1:blocks
for i = 1:nest
g(m,i,1) = normrnd(c(i),d(i))
a(m,i,2) = normrnd(g(m,i,1),d(i));
for n=2:draws;
a(m,i,n)=normrnd(a(m,i,n-1),d(i));
end
end
end
.
Error using parfor_exercise (line 13)
Error: The variable g in a parfor cannot be classified.

2 个评论

Which line is line 13?
It's where the parfor begins.

请先登录,再进行评论。

 采纳的回答

parfor m = 1:blocks
gm = zeros(1, nest);
for i = 1:nest
gm(1,i) = normrnd(c(i), d(i))
a(m,i,2) = normrnd(gm(1,i), d(i));
for n=2:draws;
a(m,i,n)=normrnd(a(m,i,n-1),d(i));
end
end
g(m, :, 1) = gm;
end

3 个评论

It's giving me the following error:
Error: The variable a in a parfor cannot be classified.
g = zeros(blocks, nest, SomeSize);
a = zeros(blocks, nest, draws);
parfor m = 1:blocks
gm = zeros(1, nest);
am = zeros(1, nest, draws);
for i = 1:nest
gm(1,i) = normrnd( c(i), d(i) )
am(1, i, 2) = normrnd( gm(1,i), d(i) );
for n=2:draws;
am(1,i,n) = normrnd( am(1,i,n-1), d(i) );
end
end
g(m, :, 1) = gm;
a(m, :, :) = am;
end
This works. Thanks a lot!

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by