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

Home » Public Forums » archive » Re: Referencing elements of array expressions
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: Referencing elements of array expressions [message #3513] Mon, 06 February 1995 08:18 Go to previous message
velt is currently offline  velt
Messages: 19
Registered: June 1994
Junior Member
In article <3guag9$nqn@marsupial.jpl.nasa.gov>, "Evan F. Fishbein" <eff@tugh.jpl.nasa.gov> writes:
> A simple question -- Is is possible to reference elements
> of array expressions. For example, can the last two lines of
> the following code:
>
> x=findgen(40)/10.0
> y=cos(2.0*!pi*x)
> i=where(abs(y) lt 1.0e-5)
> i=i(0:1)+[-1,1]
>
> be combined into one line by accessing the first
> element of the expression "where(abs(y) lt 1.0e-5)"
> without placing the vector result in a dumy array variable?

This is a simple trick-question, isn't it? The where finds no elements
satisfying the condition, so the last statement will generate an error.

However, in general you can index expressions by surrounding it
with parentheses and indexing that:

IDL> result = (expression) (elements)

For example, the last two lines above can be written:

IDL> i=( where(abs(y) lt 1.0E-5) ) (0:1) + [-1,1]

Robert Velthuizen (velt@rad.usf.edu),
Digital Medical Imaging Program of the
H. Lee Moffitt Cancer Center and Research Institute at the
University of South Florida, Tampa FL 33612.
[Message index]
 
Read Message
Read Message
Previous Topic: HELP! Trying to plot 3-D data
Next Topic: Computational Science Conference - cocidann.txt [1/1]

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

Current Time: Wed Oct 08 19:39:35 PDT 2025

Total time taken to generate the page: 0.00438 seconds