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

Home » Public Forums » archive » Re: Q:assigning arrays in steps
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: Q:assigning arrays in steps [message #4162] Wed, 10 May 1995 00:00 Go to previous message
Fergus Gallagher is currently offline  Fergus Gallagher
Messages: 41
Registered: January 1995
Member
Brett Hennig <bretth@lovelace.maths.monash.edu.au> wrote:
> I've been using idl for one whole week now,
> so excuse me if this question is stupid.
> In Fortran90 you can assign arrays like:
> x(0:10)=y(0:40:4)
> where the last 4 is a step increment.
>
> Can this sort of stuff be done with idl?
>

G'day,

Easily (not as elegant as F90, but more flexible).

You can index any elements of an array with another array. In your case:

IDL> x(0:10) = y(indgen(11)*4)

In 2D, this must be a two stage process, since, for example

x(0:10,0:10) <> x(indgen(11),indgen(11))

The latter is the vector

[x(0,0), x(1,1), x(2,2),....x(10,10)]

so you would have to write the assignment as:

IDL> tmp = y(indgen(11)*4,*) ; 11xN
IDL> x(0:10,0:10) = tmp(*,indgen(11)*4); 11x11

An additional point: you can insert an array into another (larger) array
just by specifying the offset, without the range. For example, the last
assignment above could have be written as;

IDL> x(0,0) = tmp(....)

which obviously generalises to abitrary offsets.


Fergus

=================================================
| Fergus Gallagher |
| Remote Sensing Applications Development Unit |
| British National Space Centre |
| Monks Wood |
| Huntingdon PE17 2LS / UK |
| |
| F.Gallagher@nerc.ac.uk |
| http://uh.nmt.ac.uk/bnsc/fgg.html |
=================================================
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Zeiger in IDL
Next Topic: Font ADVICE needed please

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

Current Time: Wed Mar 25 05:15:17 PDT 2026

Total time taken to generate the page: 0.03259 seconds