Re: IDL FOR Loop variable increments [message #62608 is a reply to message #62607] |
Thu, 18 September 2008 15:00   |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
> k=1
> for b=0,8 do begin ; Number of bands
> j=7
> c=b+k
> if b gt 0 and b ne (c) then continue
So, in this case, you go back to the for loop and increase b...
so, you have the first iteration with b=0 (this above statement is not
executed when b=0). Then, you increase b, so 'b gt 0' is true, and 'b ne
c' is also always true... k >= 1, so b+ k will NEVER be equal to b ...
so the above statement is always executed, until b > 8.
Jean
> for k=1, j do begin ; Iterations within bands
> if c lt 7 then begin
> if finite(ndvislice[s,b+k]) eq 1 then begin
> if ndvislice[s,b+k] ge ndvislice[s,b] then begin
> ndvi[s,b+k]=ndvislice[s,b+k]
> break
> endif else begin
> if ndvislice[s,b+k] lt ndvislice[s,b] then begin
> ndvi[s,b+k]=mask[s,r]
> endif
> endelse
> endif else begin
> ndvi[s,b+k]=mask[s,r]
> endelse
> endif
> endfor
> ENDFOR
>
> In the code above, i want b ( the number of bands) to be incremented
> by the value (b+k) instead of standard consistent increments of 1 or
> 2.. So, instead of b progressing from 0 to 8 as 0,1,2,3 etc..i want it
> to iterate based on the value of (b+k) derived out of the inner FOR
> loop (for k=1, j). My results run correctly but those pixels for which
> 'b' needs a (b+k) increment are not recogized by the line "if b gt 0
> and b ne (c) then continue" and so it keeps skipping all 'b'
> iterations. 'c' here is just a variable assigned to the value of b+k.
>
> Where am i going wrong ? Please let me know if you need more
> information.
>
> Thanks,
> Raghu
|
|
|