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

MathGroup Archive 1998

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

Search the Archive

Re: TableHeadings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg15081] Re: TableHeadings
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Thu, 10 Dec 1998 03:13:11 -0500
  • References: <74lefg$ski@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Roger Mason wrote in message <74lefg$ski at smc.vnet.net>...
>Hi,
>
>I wish to tabulate the values returned by a function of two variables,
>with the columns and rows labelled using the TableHeadings option to
>TableForm. The code I am using is given below.
>
>s[n_,c_]:=If[n<c^2,"n < c^2",If[n>c, "n > c",(n-c^2)/(c-c^2)]] (*
>function definition *)
>
>TableForm[Table[s[n,c], {c, 0.1, 1, 0.1}, {n, 0.1, 1, 0.1}],
>TableHeadings->{{c},{n}}]
>
>This, of course just labels the first row and first column with c and n,
>respecitvely. What I want is to have the appropriate numerical values
>of c and n, as used in the function s[c_,n_], as labels. can it be done
>using TableHeadings? I not, what is the best way to accomplish what I
>want?
>
>Thanks,
>
>Roger Mason
>
>

Roger:

s[n_, c_] :=
  If[n < c^2, "n < c^2",
    If[n > c, "n > c", (n - c^2)/(c - c^2)]] (*function definition*)
TableForm[Table[s[n, c], {c, 0.1, 1, 0.1}, {n, 0.1, 1, 0.1}],
  TableHeadings -> {{c}, {n}}]

1)
TableForm[Table[s[n, c], {c, 0.1, 1, 0.1}, {n, 0.1, 1, 0.1}],
  TableHeadings -> {Table[c, {c, 0.1, 1, 0.1}], Table[c, {c, 0.1, 1,
0.1}]}]

2)
MapThread[Prepend, {
      Prepend[Table[s[n, c], {c, 0.1, 1, 0.1}, {n, 0.1, 1, 0.1}],
        Table[c, {c, 0.1, 1, 0.1}]],
      Prepend[Table[c, {c, 0.1, 1, 0.1}], "c \\ n"]}] // TableForm

Allan

---------------------
Allan Hayes
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Re: nice Gotcha!
  • Next by Date: Re: mathematica and statistics
  • Previous by thread: TableHeadings
  • Next by thread: Re: TableHeadings