Use Parfor error:Subscripted assignment dimension mismatch

1 次查看(过去 30 天)
Hi, I came across the following errors when running the parallel codes. If I use 'parfor',matlab will appear this error:Subscripted assignment dimension mismatch. parfor j=1:1000
But if I use 'for',this error will not appear.I'm very confused about this problem.Can anyone help me,please? Thanks.
The code:
X=load('x.txt');
Y=load('y.txt');
XY=[Y,X];
[a,b]=size(XY);
N=10;
inOption.tol = 1e-6;
inOption.maxit = 50;
inOption.bctype = 1;
inOption.maxcmp = 50;
inOption.maxvar = a/2;
ptype='ebtz';
inOption.ptype = ptype;
inOption.delta = 0.1;
msc = [2 3 0:0.1:1];
parfor j=1:50
B=zeros(0,b);
for i=1:a
B=[B;XY(randi([1,a]),:)];
end
x=B(:,2:end);
y=B(:,1);
x=Standardize(x);
y=Standardize(y);
ret=POCREPath(y,x,inOption);
for k=1:13
fRes=SelectModel(a,ret,msc(k));
lambda=fRes.lambda;
end
retRes{:,j}=POCRE(y,x,lambda,inOption);
end
  2 个评论
Edric Ellis
Edric Ellis 2014-6-4
What is the output of POCRE? Does it help to pre-allocate "retRes" before the start of the loop?
Kaibing Yang
Kaibing Yang 2014-6-7
Output of POCRE is a struct.I've solve the problem.I changed retRes{:,j} to retRes(:,j) ,and the error will not appear.Thank you !

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by