Re: About TableForm
- To: mathgroup at smc.vnet.net
- Subject: [mg74376] Re: About TableForm
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Mon, 19 Mar 2007 21:56:27 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <etlq33$r84$1@smc.vnet.net>
Evanescence wrote:
> Hello Dear all:
> My questions are as follows:
> First I definition a function is f[x_,y_]:=2x+3y
> Then I use the Table so: Table[f[x,y],{x,0,3,1},{y,0,4,2}]
> Then we can get the answers :{{0,6,12},{2,8,14},{4,10,16},{6,12,18}}
> But I want to get the form as follows:
>
> x y f[x,y]
> 0 0 0
> 0 2 6
> 0 4 12
> 1 0 2
> 1 2 8
> 1 4 14
> 2 0 4
> 2 2 10
> 2 4 16
> 3 0 6
> 3 2 12
> 3 4 18
>
> Please tell me how can I do it
> Thank you very much
> Evanescence 2007 03 19
>
>
Build your list with the x and y coordinates included and use the
options TableHeadings and TableAlignments, for instance.
In[1]:=
f[x_, y_] := 2*x + 3*y
tbl = Flatten[Table[{x, y, f[x, y]}, {x, 0, 3, 1}, {y, 0, 4, 2}], 1]
TableForm[tbl, TableHeadings -> {None, {"x", "y", "f[z,y]"}},
TableAlignments -> Right]
Regards,
Jean-Marc