Re: IDL FOR Loop variable increments [message #62605 is a reply to message #62603] |
Thu, 18 September 2008 18:31   |
raghuram
Messages: 32 Registered: February 2008
|
Member |
|
|
On Sep 18, 2:52 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca>
wrote:
> Could you comment on the "risk" of changing the loop counter within the
> loop?
>
> Jean
Ok here's the scene. In my example, lets say b=0 and k=2 (i.e. b+k=
0+2 = 2) satisfies my condition, thats like saying i'm comparing
Bands '0' and '2' as in line 9, "if ndvislice[s,b+k] ge ndvislice[s,b]
then begin". The next thing i want to do is to
compare bands '2' and '3'. Its because band 1 does not satisy my
condition and i don't want the code to look at band 1 again.
Hence i want to skip from band 0 to band 2. This is primarily because
when k was 1 (b+k=0+1=1), the condition was not satisfied which
is why 'k' changes to 2. The increments are not necessarily consistent
either. I may want to skip from band 4 to band 7 if bands 5 and 6
do not satisfy my condition which in the above code is on the 9th line
"if ndvislice[s,b+k] ge ndvislice[s,b] then begin ".
So, the reason why i try to set b to b+k is just so that 'b' turns to
'b+k' as in, b=0 to 'b+2" which means i want the new b,
or the b in the next FOR loop iteration to change to 2 from 0 instead
of changing to 1.
Maybe there's a better way to do this. I hope i'm being clear.
Looking forward to a reply,
Raghu
|
|
|