필터 지우기
필터 지우기

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 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