フィルターのクリア

Doubts with parfor loop

2 ビュー (過去 30 日間)
Javier
Javier 2011 年 7 月 29 日
Hi, I'm a litte bit confused with error given in this parfor loop:
parfor n=1:fbaseDatosAct
veDelanteMiaTemp=zeros(1,3);
baseDatosRow = baseDatosAct(n,:);
veDelanteMiaTemp=vehDelanteMia(baseDatosAct,n,t);
[baseDatosRow(1),estaParado]=reduceVelocidad(t,baseDatosRow,vmin,veDelanteMiaTemp,pasoTemp);
baseDatosAct(n,:) =baseDatosRow;<-HERE TROUBLE WITH PARFOR!!
end
Why in the last sentence do I get a error saying that I cannot use parfoor loop due to the baseDatosAct use?? I've got another code whit a similiar use and I don't get this warning.
Another doubt, I can use pafor loop with logical indexing a matrix like this:
for n=1:1:fbDActual
indice=find(bDAnterior(:,columnaID)==bDActual(n,columnaID));
do something...
end
end
Where bDAnterior and bDActual both are matrixes of nx8.
Thanks Javier

回答 (1 件)

Edric Ellis
Edric Ellis 2011 年 8 月 1 日
The problem is that you're using the whole value of 'baseDatosAct' in the line:
veDelanteMiaTemp=vehDelanteMia(baseDatosAct,n,t);
Is that what you intended? If so, the loop is not order-independent because you're updating 'baseDatosAct' and using the values next time around the loop.
  1 件のコメント
Javier
Javier 2011 年 8 月 1 日
Yes it was. I have to use the whole value of 'baseDatosAct' in the function,however, I found out a solution doing this:
bdAct=zeros(fbaseDatosAct,cbaseDatosAct);
bdAct=baseDatosAct;
parfor n=1:fbaseDatosAct
veDelanteMiaTemp=zeros(1,3);
baseDatosRow = bdAct(n,:);
[veDelanteMiaTemp(1),veDelanteMiaTemp(2),veDelanteMiaTemp(3)]=vehDelanteMia(baseDatosAct,n,t);
[baseDatosRow(1),estaParado]=reduceVelocidad(t,baseDatosRow,vmin,veDelanteMiaTemp,pasoTemp);
bdAct(n,:) =baseDatosRow;
end
baseDatosAct=bdAct

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeParallel for-Loops (parfor) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by