Effacer les filtres
Effacer les filtres

Use Parfor error:Subscripted assignment dimension mismatch

1 vue (au cours des 30 derniers jours)
Kaibing Yang
Kaibing Yang le 3 Juin 2014
Commenté : Kaibing Yang le 7 Juin 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 commentaires
Edric Ellis
Edric Ellis le 4 Juin 2014
What is the output of POCRE? Does it help to pre-allocate "retRes" before the start of the loop?
Kaibing Yang
Kaibing Yang le 7 Juin 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 !

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by