Looping over odd values only [message #93028] |
Wed, 13 April 2016 04:48  |
omar ali
Messages: 13 Registered: December 2015
|
Junior Member |
|
|
Hi,
I need to make a for loop over odd values only. for example
for n=0, 15 do begin
If n eq odd value (1, 3, 5, ... etc) then begin
calculations
endif
endfor
Thanks in advance,
Omar
|
|
|
Re: Looping over odd values only [message #93029 is a reply to message #93028] |
Wed, 13 April 2016 04:53   |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
IDL> for i=1,15,2 do print,i
1
3
5
7
9
11
13
15
On Wednesday, April 13, 2016 at 7:48:47 AM UTC-4, omar ali wrote:
> Hi,
> I need to make a for loop over odd values only. for example
> for n=0, 15 do begin
> If n eq odd value (1, 3, 5, ... etc) then begin
> calculations
> endif
> endfor
>
> Thanks in advance,
>
> Omar
|
|
|
Re: Looping over odd values only [message #93030 is a reply to message #93029] |
Wed, 13 April 2016 05:29   |
omar ali
Messages: 13 Registered: December 2015
|
Junior Member |
|
|
بتاريخ الأربعاء، 13 أبريل، 2016 1:53:06 م UTC+2، كتب wlandsman:
> IDL> for i=1,15,2 do print,i
> 1
> 3
> 5
> 7
> 9
> 11
> 13
> 15
>
> On Wednesday, April 13, 2016 at 7:48:47 AM UTC-4, omar ali wrote:
>> Hi,
>> I need to make a for loop over odd values only. for example
>> for n=0, 15 do begin
>> If n eq odd value (1, 3, 5, ... etc) then begin
>> calculations
>> endif
>> endfor
>>
>> Thanks in advance,
>>
>> Omar
Thanks wlandsman, it works
|
|
|
Re: Looping over odd values only [message #93034 is a reply to message #93028] |
Wed, 13 April 2016 08:09  |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
On 04/13/16 07:48, omar ali wrote:
> Hi,
> I need to make a for loop over odd values only. for example
> for n=0, 15 do begin
> If n eq odd value (1, 3, 5, ... etc) then begin
> calculations
> endif
> endfor
>
> Thanks in advance,
Your question has been answered, but the Harris Docs Center is pretty
good too. See http://www.harrisgeospatial.com/docs/FOR.html
cheers,
paulv
|
|
|