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