1
$\begingroup$

Suppose I have three tables with index 1, 2, 3

 tab[1] = Table[{i, 2*i, 3*i}, {i, 1, 5, 1}];
 tab[2] = Table[{i, 4*i, 5*i}, {i, 1, 5, 1}];   
 tab[3] = Table[{i, 6*i, 7*i}, {i, 1, 5, 1}];

I can join one under the other with

 Join[tab[1], tab[2], tab[3]];

To get desired result

enter image description here

Now suppose I have many, many tables with index up to large number N so that the above line of code is unsuitable.

How to join N tables one under the other in this case?

$\endgroup$
3
  • 3
    $\begingroup$ You can use Apply: n = 3; Join @@ Table[tab[i], {i, n}]. $\endgroup$ Commented Jun 5 at 14:45
  • 3
    $\begingroup$ Or Catenate: Catenate[Table[tab[i], {i, 1, n}]]. $\endgroup$ Commented Jun 5 at 15:18
  • 1
    $\begingroup$ You can also use Array: Catenate[Array[tab, n]] $\endgroup$ Commented Jun 5 at 15:19

1 Answer 1

3
$\begingroup$

You can use ArrayFlatten.

With

tabs = Table[{1,Sequence@@#}*i,{i,5}]& /@ Partition[Range[2,7], 2];

Tables can be referenced by Part. For example tabs[[1]] for first table. Also, increase 7 in the above to a higher odd number for more tables.

Then

stacked = ArrayFlatten[List/@tabs];
MatrixForm@stacked

This returns the stacked matrix.

Hope this helps.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.