MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: A matrix element specified by a vector?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg123354] Re: A matrix element specified by a vector?
  • From: Ulrich Arndt <ulrich.arndt at data2knowledge.de>
  • Date: Sat, 3 Dec 2011 04:12:34 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201112021221.HAA01882@smc.vnet.net>

myMatrix = Table[RandomReal[], {10}, {10}];
myMatrix // TableForm
myVec = Table[RandomInteger[{1, 10}], {2}]

Extract[myMatrix, myVec]
myMatrix[[Apply[Sequence, myVec]]]

3 dim

myMatrix = Table[RandomReal[], {10}, {10}, {10}];
myVec = Table[RandomInteger[{1, 10}], {3}]
Extract[myMatrix, myVec]
myMatrix[[Apply[Sequence, myVec]]]

Is it this what you want?

Ulrich

Am 02.12.2011 um 13:21 schrieb Ralph Dratman:

> I am wondering if there is a more compact way to express the following idea:
>
> myMatrix[[   myVector[[1]],  myVector[[2]]   ]]  =  myScalar
>
> This keeps coming up. Did I miss the quick and easy way to do it? Of
> course it looks even uglier in 3 dimensions.
>
> Thank you.
>
> Ralph Dratman
>




  • Prev by Date: Re: A matrix element specified by a vector?
  • Next by Date: Delete close, but not identical elements in an array
  • Previous by thread: Re: A matrix element specified by a vector?
  • Next by thread: Re: A matrix element specified by a vector?