Use Parfor error:Subscripted assignment dimension mismatch

1 回表示 (過去 30 日間)
Kaibing Yang
Kaibing Yang 2014 年 6 月 3 日
コメント済み: Kaibing Yang 2014 年 6 月 7 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by