comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Looping over odd values only
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Looping over odd values only [message #93028] Wed, 13 April 2016 04:48 Go to next message
omar ali is currently offline  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 Go to previous messageGo to next message
wlandsman is currently offline  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 Go to previous messageGo to next message
omar ali is currently offline  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 Go to previous message
Paul Van Delst[1] is currently offline  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
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: How can I make the headers of two fits files same in IDL?
Next Topic: Should SORT(Undefined) give an error message?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:37:11 PDT 2025

Total time taken to generate the page: 0.00493 seconds