MathGroup Archive 2006

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

Search the Archive

Re: adding matrices

  • To: mathgroup at smc.vnet.net
  • Subject: [mg65797] Re: adding matrices
  • From: "J Siehler" <jsiehler at gmail.com>
  • Date: Mon, 17 Apr 2006 02:28:53 -0400 (EDT)
  • References: <e1sv6v$ct3$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

>if i type m-p, mathematica treats the second matrix p as a scalar and subtracts that entire 3x3
>matrix p from each entry of m

If m and p have the same dimensions then Mathematica will subtract (or
add) entry-by-entry the way you want.  You might want to clarify what
you mean by "subtracts [a matrix] from each 3x3 entry m" because that's
a little unclear; better, post your code so we can see what's
happening.

--

In[8]:=
m=Array[Random[Integer,{-10,10}]&,{3,3}]
p=Array[Random[Integer,{-10,10}]&,{3,3}]

Out[8]=
{{6,1,-7},{2,9,-3},{1,1,8}}

Out[9]=
{{1,9,5},{-3,-10,9},{9,5,6}}

In[10]:=
m-p

Out[10]=
{{5,-8,-12},{5,19,-12},{-8,-4,2}}


  • Prev by Date: Re: mathematica programming
  • Next by Date: Re: Resetting Mathematica
  • Previous by thread: Re: adding matrices
  • Next by thread: Re: adding matrices