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


Groups > comp.soft-sys.math.mathematica > #6909 > unrolled thread

Re: A matrix element specified by a vector?

Started byBob Hanlon <hanlonr357@gmail.com>
First post2011-12-03 09:16 +0000
Last post2011-12-03 09:16 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: A matrix element specified by a vector? Bob Hanlon <hanlonr357@gmail.com> - 2011-12-03 09:16 +0000

#6909 — Re: A matrix element specified by a vector?

FromBob Hanlon <hanlonr357@gmail.com>
Date2011-12-03 09:16 +0000
SubjectRe: A matrix element specified by a vector?
Message-ID<jbcpcr$bj5$1@smc.vnet.net>
n = RandomInteger[{2, 6}]

4

myVector = RandomSample[Range[n]]

{4, 3, 2, 1}

myMatrix = Array[m, Table[n, {n}]];

myMatrix[[Sequence @@ myVector]] = myScalar;

Flatten[Position[myMatrix, myScalar]] == myVector

True


Bob Hanlon


On Fri, Dec 2, 2011 at 7:21 AM, Ralph Dratman <ralph.dratman@gmail.com> wrote:
> 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

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web