for to parfor loop,and for with logical indexing to parfor loop
조회 수: 1 (최근 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!