Re: Matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg82076] Re: Matrices
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 11 Oct 2007 00:23:01 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fei2sd$qf3$1@smc.vnet.net>
KFUPM wrote:
> Dear Group
>
> I have two matrices
>
> H= {{a,b},{c,d}}
> and
> L ={{1,2},{3,4}}
>
> and I want the element "a" in matrix H to have the corresponding
> numerical values of L , i.e 1 and b --> 2 and so on. I am wondering
> how to do that in the simplest way possible? My actual matrices are
> larger than those i introduce here, i did that just for simplicity.
>
> Any help in this regard is highly appreciated.
Well, if the obvious H = L is not enough, you could use *Thread* among
many other ways.
In[1]:= H = {{a, b}, {c, d}};
L = {{1, 2}, {3, 4}};
H = L;
H
Out[4]= {{1, 2}, {3, 4}}
In[5]:= H = {{a, b}, {c, d}};
L = {{1, 2}, {3, 4}};
Thread[Set[H, L]];
H
Out[8]= {{1, 2}, {3, 4}}
Regards,
--
Jean-Marc