1
$\begingroup$

I have the following Table:

Clear["Global`*"]; 
Module[{startX = 10, endX = 12, endJ = 5},
  table1 = Table["", {j, 1, endJ}]; 
  table2 = Table[x/j, {x, startX, endX}, {j, 1, endJ}]; 
  table3 = Table[j/x, {x, startX, endX}, {j, 1, endJ}]; 
  table4 = Table[N[Sqrt[x]/j^2 - j^2/x], {x, startX, endX}, {j, 1, endJ}]; 
  table5 = Riffle[table2, table3]; 
  table6 = Riffle[table5, table4, 3]; 
  table7 = Riffle[table6, table1, 4];]

The idea is that there are four consecutive rows for each value x, each displaying the relevant values from table1, table2, table3 and table4. But I have a few problems:

  1. table7 is missing its last line - here's a screenshot:

enter image description here

  1. TableForm[table7] displays correctly, but

     TableForm [table7, 
       TableHeadings -> 
         {{"x=1", "", "", "", "2", "", "", "", "3", "", "", ""}, 
          {"j=1", "2", "3", "4", "5"}}]
    

    does not — there are no dividers.

  2. Although TableForm[table7] works, Grid [table7] does not. (Update: @kglr has solved this issue in the comments below)

Can anyone help me fix these issues?

Ideally, I would prefer a solution using Grid since this allows more flexibility with dividers.

$\endgroup$
4
  • $\begingroup$ for problem 3: replace "" in table7 with {""}; that is, use Grid[table7 /. "" -> {""}]. $\endgroup$ – kglr Aug 30 '20 at 11:55
  • $\begingroup$ Many thanks @kglr $\endgroup$ – Richard Burke-Ward Aug 30 '20 at 12:15
  • 1
    $\begingroup$ Your 1st question is weird. There is no table6 used in the definition of table5. Is that a typo or did I miss something? $\endgroup$ – halirutan Aug 30 '20 at 16:21
  • $\begingroup$ Hi @halirutan. Question amended and clarified. Thanks for the heads-up. $\endgroup$ – Richard Burke-Ward Aug 31 '20 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.