Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6912

Re: A matrix element specified by a vector?

From Ulrich Arndt <ulrich.arndt@data2knowledge.de>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: A matrix element specified by a vector?
Date 2011-12-03 10:07 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jbcscg$bve$1@smc.vnet.net> (permalink)
References <201112021221.HAA01882@smc.vnet.net>

Show all headers | View raw


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
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: A matrix element specified by a vector? Ulrich Arndt <ulrich.arndt@data2knowledge.de> - 2011-12-03 10:07 +0000

csiph-web