Re: About TableForm
- To: mathgroup at smc.vnet.net
- Subject: [mg74372] Re: About TableForm
- From: "dimitris" <dimmechan at yahoo.com>
- Date: Mon, 19 Mar 2007 21:54:14 -0500 (EST)
- References: <etlq33$r84$1@smc.vnet.net>
Hello.
Copy/Paste the following to a notebook, select the cell and press Shift
+Enter
Print["your function"]
f[x_, y_] = 2*x + 3*y
Print["your list of data"]
dat = Table[f[x, y], {x, 0, 3, 1}, {y, 0, 4, 2}]
Print["your desired output"]
dat // TableForm[#1, TableAlignments -> Center, TableSpacing -> {2,
2},
TableHeadings -> {None, (StyleForm[#1, FontSize -> 14, FontColor ->
Red] & ) /@ {"x", "y", "f[x,y]"}}] &
The key here is TableForm and its Options.
?? TableForm
TableForm[list] prints with the elements of list arranged in an array
of \
rectangular cells.
Attributes[TableForm] = {Protected, ReadProtected}
Options[TableForm] := {TableAlignments -> Automatic, TableDepth ->
Infinity, TableDirections -> Column, TableHeadings -> None,
TableSpacing -> Automatic}
Execute the following command to get futher information about its
Options
Options[TableForm];
(Information[Evaluate[#1[[1]]]] & ) /@ %;
"TableAlignments is an option for TableForm and MatrixForm which
specifies how entries in each dimension should be aligned."
Attributes[TableAlignments] = {Protected}
"TableDepth is an option for TableForm and MatrixForm which specifies
the maximum number of levels to be printed in tabular or matrix
format."
Attributes[TableDepth] = {Protected}
"TableDirections is an option for TableForm and MatrixForm which
specifies whether successive dimensions should be arranged as rows or
columns."
Attributes[TableDirections] = {Protected}
"TableHeadings is an option for TableForm and MatrixForm which gives
the labels to be printed for entries in each dimension of a table or
matrix."
Attributes[TableHeadings] = {Protected}
"TableSpacing is an option for TableForm and MatrixForm which
specifies how many spaces should be left between each successive row
or column."
Attributes[TableSpacing] = {Protected}
Also
FrontEndExecute[{HelpBrowserLookup["MainBook", "TableForm"]}]
Dimitris
P=2ES
Note that searching to my archives you can see a post of mine asking
how is it possibly
to get a table similar to that it would appear in a book (i.e. draw
vertical and horizontal lines
between rows and columns!).
=CF/=C7 Evanescence =DD=E3=F1=E1=F8=E5:
> 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