for to parfor loop,and for with logical indexing to parfor loop
2 次查看(过去 30 天)
显示 更早的评论
Hi, I have got two doubts:
-> the first one is to change this for loop to parfor loop, I have done all, but due to the last sentence I cannot use the parfor loop:
ORGINAL LOOP:
for n=1:fbaseDatosAct
[vehDel(1),vehDel(2),vehDel(3)]=vehDelanteMia(baseDatosAct,n,t);
[baseDatosAct(n,columnaV),estaParado]=reduceVelocidad(t,baseDatosAct(n,:),vmin,vehDel,pasoTemp);
end
PARFOR LOOP:
parfor n=1:fbaseDatosAct
veDelanteMiaTemp=zeros(1,3);%variable estatica para la paralelizacion
baseDatosRow = baseDatosAct(n,:);%variable estatica para la paralelizacion
veDelanteMiaTemp=vehDelanteMia(baseDatosAct,n,t);
[baseDatosRow(1),estaParado]=reduceVelocidad(t,baseDatosRow,vmin,veDelanteMiaTemp,pasoTemp);
baseDatosAct(n,:) =baseDatosRow;<-HERE TROUBLE WITH PARFOR!!
end
->My second doubt with parfor is if I could convert a for loop which contents a logical indexing to parfor one, for example the original for loop would be the next code, where bDActual and bDAnterior are matrix of nx8.
for n=1:1:fbDActual
indice=find(bDAnterior(:,columnaID)==bDActual(n,columnaID));
if(~isempty(indice))
if((bDAnterior(indice,columnaInc)~=0) && (bDActual(n,columnaInc)==0))
bDActual(n,columnaV)=bDActual(n,columnaV)+incrVel;
if(bDActual(n,columnaV)>vMax)
bDActual(n,columnaV)=vMax;
end
end
end
end
Thanks, Javier
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!