Logical indexing within parfor statement

조회 수: 3 (최근 30일)
Javier
Javier 2011년 8월 1일
Hi. I have a problem with parfor and an indexing. As you can see in my code below, I get a group of elements of a matrix using find, then I use these indexes to select the elements I need to. So it's said to me that is an error due to the way I've indexed. Any suggestion?
baseDatosFilaTemp=zeros(1,8);
tempBaseDatosIDs=zeros(cbdAcelerados,1);
tempBaseDatosIDs=baseDatos(:,columnaID);
parfor n=1:fbdAcelerados
bdAceleradosFila=zeros(1,8);
bdAceleradosFila=bdAcelerados(n,:);
indice=find(tempBaseDatosIDs==bdAceleradosFila(colAcID));
if(~isempty(indice))
if(bdAceleradosFila(colAcT)>=0)
baseDatosFilaTemp=baseDatos(indice,:);%*<-HERE TROUBLE*
baseDatosFilaTemp(columnaV)=incrVel+baseDatosFilaTemp(columnaV);
if(baseDatosFilaTemp(columnaV)>vMax)
baseDatosFilaTemp(columnaV)=vMax;
end
baseDatos(indice,:)=baseDatosFilaTemp;
end
end
end
Thanks,Javier
  댓글 수: 3
Javier
Javier 2011년 8월 1일
The expected output is an update of baseDatos matrix elements which are in the matrix bdAcelerados too. The issue to use pafoor is the dimension of baseDatos which could be 500x8 for example.
Javier
Javier 2011년 8월 1일
Sorry the example:
baseDatos=[ 10 22 1 1 1 1 1 2
20 33 1 2 4 5 7 9]
bdAcelerados =[ 2 2 2]
Then the update will be:
baseDatos=[ 10+incrVel 22 1 1 1 1 1 2
20 33 1 2 4 5 7 9]

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2011년 8월 1일
You've stated, that there are "troubles". I guess, that this does not mean an error, but a warning of MLint?! Does it say, that you can omit the FIND? Then I suggest:
% Omit this useless line: bdAceleradosFila=zeros(1,8);
bdAceleradosFila=bdAcelerados(n,:);
indice = (tempBaseDatosIDs==bdAceleradosFila(colAcID));
if any(indice)
if bdAceleradosFila(colAcT) >= 0
baseDatosFilaTemp = baseDatos(indice,:);
...
  댓글 수: 1
Javier
Javier 2011년 8월 2일
Hi Jan, thanks for replying!
Yes I have got a warnning produced by the parfor loop, to be precise, due to the use of baseDatos. I've made the changed you have suggested to me, but despite them, I still get the warnning...
Thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by