for to parfor loop,and for with logical indexing to parfor loop

1 view (last 30 days)
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

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!