Variable in PARFOR

Hi
I have a loop in my code for calculating a matrix that index of matrix, determined in loop. for example:
for ii=1:100
pos=find(A==ii);
.
.
.
Z(:,pos)=Z(:,pos)+...
.
.
.
end
which A is another matrix. When I try to use PARFOR, an error occured for variable pos. I read PARFOR help in matlab, but I didn't get any idea how can I correct that. can anyone help me to write correct code for PARFOR?

Antworten (2)

Walter Roberson
Walter Roberson am 26 Jul. 2011

0 Stimmen

Including the error message would help.
My speculation is that the analyzer is not able to determine that you are "slicing" Z in non-overlapping ways.
If so, then I do not know enough about PARFOR to be able to suggest a work-around.

3 Kommentare

rahman
rahman am 26 Jul. 2011
Error: The variable Z in a parfor cannot be classified.
Walter Roberson
Walter Roberson am 26 Jul. 2011
Are you initializing Z outside of the loop? Is the value of Z needed after the loop?
rahman
rahman am 26 Jul. 2011
Yes. Befor loop started I initialized Z=zeros(N).
Yes. I use Z after loop

Melden Sie sich an, um zu kommentieren.

Konrad Malkowski
Konrad Malkowski am 3 Aug. 2011

0 Stimmen

What are you trying to do with Z variable? Do you use it to accumulate some values (reduction variable) across all iterations? Or, do you update a single column of Z in each iteration? I would need more information on this loop and variable in order to help you.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 26 Jul. 2011

Community Treasure Hunt

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

Start Hunting!

Translated by