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

Home » Public Forums » archive » For..Do Loop and If statements
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: For..Do Loop and If statements [message #94100 is a reply to message #94098] Thu, 19 January 2017 02:44 Go to previous messageGo to previous message
Markus Schmassmann is currently offline  Markus Schmassmann
Messages: 129
Registered: April 2016
Senior Member
On 01/19/2017 10:06 AM, Helder wrote:
> That should then work. However, IDL is not made for loops. The
> typical way to do this is to use the where function
> (http://www.harrisgeospatial.com/docs/WHERE.html):
>
> b2 = a[where(a gt 5)]
>
> if you're not sure if any elements of a are greater than 5, then you
> should use: pos = where(a gt 5, cnt) if cnt gt 0 then b2 = a[pos]
> else b2 = []
A small addition to Helder's answer:
if there might be elements greater than 5, you could also use:

b2 = a[where(a gt 5,/NULL)]

this avoids the use of if...then, which is rather slow in IDL

Markus
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL 8.6 demo mode
Next Topic: How to run correl_optimize IDL code

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

Current Time: Sun Oct 12 00:08:15 PDT 2025

Total time taken to generate the page: 1.03665 seconds