Basic Array Subscripting Question [message #80304] |
Thu, 31 May 2012 02:38  |
rjp23
Messages: 97 Registered: June 2010
|
Member |
|
|
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?
|
|
|
Re: Basic Array Subscripting Question [message #80441 is a reply to message #80304] |
Fri, 01 June 2012 07:58  |
Lajos Foldy
Messages: 176 Registered: December 2011
|
Senior Member |
|
|
On Thursday, May 31, 2012 11:38:59 AM UTC+2, 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?
This is documented in 'Combining Array Subscripts':
When combining two subscript arrays, each element of the first subscript array is combined with the corresponding element of the second subscript array. The two subscript arrays must have the same number of elements. The resulting subscript array has the same number of elements as its constituents. For example, the expression A[[1, 3], [5, 9]] yields the elements A[1,5] and A[3,9].
regards,
Lajos
|
|
|