Use Parfor error:Subscripted assignment dimension mismatch

1 visualización (últimos 30 días)
Kaibing Yang
Kaibing Yang el 3 de Jun. de 2014
Comentada: Kaibing Yang el 7 de Jun. de 2014
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 comentarios
Edric Ellis
Edric Ellis el 4 de Jun. de 2014
What is the output of POCRE? Does it help to pre-allocate "retRes" before the start of the loop?
Kaibing Yang
Kaibing Yang el 7 de Jun. de 2014
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 !

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by