IDL FOR Loop variable increments [message #62614] |
Thu, 18 September 2008 12:53 |
raghuram
Messages: 32 Registered: February 2008
|
Member |
|
|
Hi all,
I'm having a problem with FOR loop increments in IDL which i'm not
able to fix. I have pasted the code and a small description about it
follows.
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
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
|
|
|