Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: About TableForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg74406] Re: [mg74356] About TableForm
  • From: leigh pascoe <leigh at cephb.fr>
  • Date: Mon, 19 Mar 2007 22:12:56 -0500 (EST)
  • References: <200703191051.FAA27863@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
>
>
>
>   
Hi,

Try the following

In[1]:= f[x_,y_]:=2x+3y
In[2]:=TableForm[Flatten[Table[{x,y,f[x,y]},{x,0,3,1},{y,0,4,2}],1],  
TableHeadings\[Rule]{None,{"x","y","F(x,y)"}}]

You can polish the output by using the options to the TableForm command 
listed in the Help for this command.

Leigh



  • Prev by Date: Re: Whitespace weirdness.
  • Next by Date: Re: Slots & Ampersands
  • Previous by thread: RE: About TableForm
  • Next by thread: Re: About TableForm