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

Home » Public Forums » archive » Re: Basic Array Subscripting Question
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
Re: Basic Array Subscripting Question [message #80302] Thu, 31 May 2012 04:25 Go to next message
Heinz Stege is currently offline  Heinz Stege
Messages: 189
Registered: January 2003
Senior Member
On Thu, 31 May 2012 02:38:59 -0700 (PDT), Rob wrote:

> This is very basic stuff but for some reason it's leaving me stumped.
>
> I always thought that:
>
> array[412:413, 18:19] was equivalent to array[[412,413], [18,19]]
>
> but the first returns a 2,2 array (which I want) whilst the second
> only returns a 2 element array.
>
> <Expression> DOUBLE = Array[2, 2]
> <Expression> DOUBLE = Array[2]
>
> Any idea what I'm doing wrong?
>
There is a third way which is very similar to your 2nd expression, but
returns the 2 by 2 array:
b=array[[412,413], [18,19], 0]
or
b=array[[412,413], [18,19], *]

Heinz
Re: Basic Array Subscripting Question [message #80303 is a reply to message #80302] Thu, 31 May 2012 03:20 Go to previous messageGo to next message
greg.addr is currently offline  greg.addr
Messages: 160
Registered: May 2007
Senior Member
They're not the same. The second gives you [array[412,18],array[413,19]], which is often needed - the index arrays are enumerated pairwise. I think this means that when there's a colon present, the whole indexing expression is treated differently.

What I find odd is that you can make an expression a=b[3:5] giving b[[3,4,5]], but you can't have a=[3:5] giving a=[3,4,5], which would be very useful.

greg
Re: Basic Array Subscripting Question [message #80442 is a reply to message #80302] Fri, 01 June 2012 06:41 Go to previous message
rjp23 is currently offline  rjp23
Messages: 97
Registered: June 2010
Member
On May 31, 12:25 pm, Heinz Stege <public.215....@arcor.de> wrote:
> There is a third way which is very similar to your 2nd expression, but
> returns the 2 by 2 array:
>    b=array[[412,413], [18,19], 0]
> or
>    b=array[[412,413], [18,19], *]
>
> Heinz

Ah that's why it was confusing me. That behaviour and the behaviour I
posted earlier don't seem consistent with each other, do they?
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: put a variable in 2D-array to plot a contour on a map.
Next Topic: Basic Array Subscripting Question

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

Current Time: Fri Oct 10 10:07:44 PDT 2025

Total time taken to generate the page: 1.20065 seconds