Object Indices in parfor loop

Hello,
I am trying to parallelize some code involving cellular signaling models. I am using an object called "ppiUpdater," which is defined by a class I've written. I am trying to call a function using that object inside a parfor loop and matlab tells me that the object ppiUpdater is not properly indexed.
Here is the code for the parfor loop:
newState=zeros(NCells, 1);
parfor iCell = 1:NCells
newState(iCell,1).ActiveReceptors = ...
ppiUpdater.evolveReceptors(arguments involving iCell);
end
Thanks in advance for any help!

댓글 수: 2

Satyajeet Sasmal
Satyajeet Sasmal 2015년 8월 17일
Hi Ondrej,
Can you post your code and all relevant data that you use, here, so that I can reproduce the error?
Also, You might be incorrectly referencing your parfor loop. You can only reference the "i-th" element (not "(i+1)-th" or "(i-1)-th" elemnt) in "i-th" iteration of the loop. Please refer to the third paragraph of the link mentioned below for possible issue resolution.
Walter Roberson
Walter Roberson 2015년 8월 21일
(i+1) and (i-1) are valid for indexing for loop variable i, but it must be consistent -- you cannot reference both (i) and (i-1) . See http://www.mathworks.com/help/distcomp/sliced-variables.html

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

답변 (1개)

Edric Ellis
Edric Ellis 2015년 8월 18일

0 개 추천

If ppiUpdater is an object instance that you're trying to call a method of, you might want to use the "functional" form of method invocation, like so:
evolveReceptors(ppiUpdater, arguments involving iCell);
This entirely equivalent to the dot-reference version, except that parfor will not interpret it as an indexing expression.

댓글 수: 1

Ondrej
Ondrej 2015년 8월 20일
Thanks all. I found the error was in another part of the code involving an instance variable associated with the object not being indexed correctly. Not sure why matlab would show the error in the above function call, but I guess it did!

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

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2015년 8월 14일

댓글:

2015년 8월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by