Re: simple questions about matrices
- To: mathgroup at smc.vnet.net
- Subject: [mg26510] Re: simple questions about matrices
- From: "Dana" <dana_news at hotmail.com>
- Date: Sat, 30 Dec 2000 01:55:21 -0500 (EST)
- References: <9217dp$cnv@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello. I am new to Mathematica, but I will give it a shot. This is probably not
the best way since I am new at this.
I am not sure how you would add an extra column to sum the Rows. Dana.
In[12]:=
tbl = Table[j + k, {j, 3}, {k, 4}];
In[13]:=
TableForm[tbl]
Out[13]//TableForm=
TableForm[{{2, 3, 4, 5}, {3, 4, 5, 6},
{4, 5, 6, 7}}]
In[40]:=
totals = Table[Plus @@ tbl[[All,j]],
{j, Dimensions[tbl][[2]]}]
Out[40]=
{9, 12, 15, 18}
In[47]:=
TableForm[Append[tbl, totals]]
Out[47]//TableForm=
TableForm[{{2, 3, 4, 5}, {3, 4, 5, 6},
{4, 5, 6, 7}, {9, 12, 15, 18}}]
"Cristian Opazo-Castillo" <cropazo at vassar.edu> wrote in message
news:9217dp$cnv at smc.vnet.net...
> Hello all:
>
> I hope that someone is still working and could help me with this...
>
> (a) I have a (m,n) matrix a with integer entries. How can I construct
> a separate list with the totals of adding the entries of either the
> rows or columns?
>
> (b) How can I construct a (m+1,n) matrix where the new row's entries
> are the sums of all numbers on each column?
>
> (c) In general, how can I attach additional columns (o rows) to an
> existing matrix?
>
> Thanks a lot and Happy Holidays,
>
> Cristian
>
>