Logical indexing within parfor statement
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (1)
Jan
il 1 Ago 2011
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,:);
...
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!