Thread Subject: multiple parfor loops, "i" is unavailable after the loop

Subject: multiple parfor loops, "i" is unavailable after the loop

From: Kirk

Date: 2 Sep, 2009 03:16:06

Message: 1 of 2

I have a script that repeats several uses of "parfor" with diferent calls in each . I use the variable "i" several times. However I am getting the error:

"The index variable "i" is used after the PARFOR loop, but it is unavailable after the loop"

Any suggestions would be appreciated.

My usage looks like:

parfor i = 1:5
  some statements;
end;

parofor i = 1:5
  some other statments;
end;

I am getting a "red" warning. However the script does run correctly. Is this one of those times when one just need to suppress the m-lint error?

Subject: multiple parfor loops, "i" is unavailable after the loop

From: Raymond Norris

Date: 25 Sep, 2009 05:54:19

Message: 2 of 2

Kirk,

With the code as you've written it, I don't believe M-Lint would ever complain about this unless (a) you've left out some code between the parfor loops which does actually use the loop index and (b) you are using the variable "i", since "i" would still work as the complex function.

Which version of MATLAB are you using and can you verify that the loop variable is not being referenced between the parfor loops?

Raymond

"Kirk" <kwythers.nospam@umn.edu> wrote in message <h7ko1m$3ct$1@fred.mathworks.com>...
> I have a script that repeats several uses of "parfor" with diferent calls in each . I use the variable "i" several times. However I am getting the error:
>
> "The index variable "i" is used after the PARFOR loop, but it is unavailable after the loop"
>
> Any suggestions would be appreciated.
>
> My usage looks like:
>
> parfor i = 1:5
> some statements;
> end;
>
> parofor i = 1:5
> some other statments;
> end;
>
> I am getting a "red" warning. However the script does run correctly. Is this one of those times when one just need to suppress the m-lint error?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
multiple parfor... Sprinceana 2 Sep, 2009 03:02:44
parfor Sprinceana 2 Sep, 2009 03:02:44
rssFeed for this Thread

Contact us at files@mathworks.com