MathGroup Archive 1999

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

Search the Archive

Re: assignment of matrix elements

  • To: mathgroup at smc.vnet.net
  • Subject: [mg17261] Re: assignment of matrix elements
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Fri, 30 Apr 1999 02:34:45 -0400
  • Organization: Universitaet Leipzig
  • References: <7g0r8r$dsc@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Richard,

with: 

m={{0,0},{0,0}};
val={1,2,3,4};
index={{1,1},{2,2},{1,2},{2,1}};

the line

Apply[Set[Part[m,Sequence @@ #1],#2]&,#] &/@Transpose[{index,val}];

will do what you want

Regards
  Jens

Richard Finley wrote:
> 
> This seems like it should be straightforward but I am too tired to think
> about it anymore:
> 
> If you have a matrix say mat = Array[m, {4,4}]
> 

SNIP  

> Obviously you can do it individually by simple assignment:
> m{1,2]=1
> 
> That won't work for me because there are thousands of elements...the
> techniques I have tried so far
> have not worked...any help is greatly appreciated.
> 
> Thanks
> 
> Richard Finley


  • Prev by Date: re: my previous question on matrix element assignment
  • Next by Date: Re: Question: getting list data into a matrix
  • Previous by thread: Re: assignment of matrix elements
  • Next by thread: directory and file structure