On Monday, February 17, 2014 6:57:10 PM UTC-6, David P. Sanders wrote: > > 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]? > 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. >
You're looking for r[pos...]. The ellipsis operator will splat the elements of pos as a comma-separated list of arguments.