Re: Basic Array Subscripting Question [message #80302] |
Thu, 31 May 2012 04:25  |
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   |
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  |
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?
|
|
|