Hi,
I am having trouble with some parallel for-loop coding. I believe my essential difficulties can be captured in the following example code.
The function "do_something(x)" takes an array as input and returns an array of equal size ("rand(size(pSlice))" would suffice for example), but this should be irrelevant. Matlab doesn't like the way I am indexing "p". After reading "documentation-center/classification-of-variables/sliced-variables", I understand (in principle) why Matlab doesnt accept "p" (incorrect form of indexing ), but what are my options to resolve this problem?
CellOccupations=round(rand(50,1)*20);p=rand([sum(CellOccupations) 3]);csO=cumsum(CellOccupations);parfor iter=1:50 StartingPointIndex=csO(iter)-CellOccupations(iter)+1; EndPointIndex=csO(iter); pSlice=p(StartingPointIndex:EndPointIndex,:); pSlice=do_something(pSlice); p(StartingPointIndex:EndPointIndex,:)=pSlice;end
I'll be happy to provide additional details and description of the problem if someone thinks they can help.
Thanks very much in advance for any help and effort!
Best Answer