El lunes, 17 de febrero de 2014 18:57:10 UTC-6, David P. Sanders escribió:
>
> Hi,
>
> Suppose I have the following:
>
> r = rand(5, 5)
>
> I can select a single element of the array r using
>
> r[3, 4]
>
> Now suppose that I have the position [3, 4] stored in a variable as
>
> pos = [3, 4]
>
> How can I use pos as the index for selecting the *single* element r[3, 4]?
>

Of course, one solution is

r[pos[1], pos[2]]

but this is not suitable for a multi-dimensional array.


 

> I would like to do r[pos], but this returns a *two*-element array, given 
> by the elements numbered 3 and 4 in the linear ordering of the array r.
>
> This sounds like a silly question, but I can't find the answer!
>
>
> Thanks,
> David.
>

Reply via email to