MathGroup Archive 2007

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

Search the Archive

Re: Matrices


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


  • Prev by Date: Re: Matrices
  • Next by Date: Re: rule based program for "Deleting repeated members of a list."
  • Previous by thread: Re: Matrices
  • Next by thread: Re: Matrices