1

I'm trying to create a certain 6x6 matrix using Mathematica's in-built "Table[]" function and have landed on

Table[Subscript[H, i, j, k, l], {i, {x, y, z}}, {j, {x, y, z}}, {k, 1,
2}, {l, 1, 2}] // MatrixForm

, which results in a 3x3 matrix with each entry corresponding to a 2x2 matrix. Instead, I actually want a plain 6x6 matrix with the same 36 entries, i.e. without the grouping into sub-matrices. How can I make this happen?

Similarly, how would I create a 6-dimensional column vector? Using "Table[]" results in two columns, e.g.

Table[Subscript[p, i, k], {i, {x, y, z}}, {k, 1, 2}] // MatrixForm

and "Array[]" does not take nested lists as argument. Without nesting I get the following error:

enter image description here

  • In light of the fact that N has reserved meaning in Mathematica, I request you to modify your post. – Syed Oct 18 '23 at 05:19
  • Also, look at FullForm[n'] and you will see that the prime mark cannot be used as part of a symbol name. It is used for differentiation. – Bob Hanlon Oct 18 '23 at 05:31
  • [ʼ] is not the same prime that Mathematica uses for differentiation [']. Mathematica can distinguish unicode characters, see https://mathematica.stackexchange.com/questions/11499/superscript-prime-symbol – ConfusedCabbage Oct 18 '23 at 06:12
  • Perhaps that's true, but it doesn't copy and paste well, so we can't run your code without modifying it by hand, so help us help you by using standard Mathematica variable names (e.g., replace n' with np). – march Oct 18 '23 at 16:15
  • I've rewritten the question in a form that I believe is more convenient to answer. – ConfusedCabbage Oct 19 '23 at 01:04
  • Yes, "ArrayFlatten[]" works for the 6x6 matrix, but it does not seem to help with the second part of my question, see my comment to the answer provided by Nasser below. – ConfusedCabbage Oct 19 '23 at 07:41
  • Try Flatten instead of MatrixFlatten for your second question. – bbgodfrey Oct 19 '23 at 13:57
  • That worked. Thanks! – ConfusedCabbage Oct 20 '23 at 07:02

1 Answers1

2

do you mean like this or something else?

(mat = Table[Subscript[H, i, j, k, l], {i, {x, y, z}}, {j, {x, y, z}}, 
    {k, 1, 2}, {l, 1, 2}]) // MatrixForm

ArrayFlatten[mat] // MatrixForm

Mathematica graphics

Nasser
  • 143,286
  • 11
  • 154
  • 359
  • Thank you! This is what I was looking for. Would you mind commenting on my second question as well, i.e. how to populate a vector array based on the iteration of two parameters? – ConfusedCabbage Oct 19 '23 at 07:40
  • 1
    @ConfusedCabbage as mentioned in comment by
    bbgodfrey, for the second one you just need normal Flattern, since it has no matrices inside the matrix. Like this Mathematica graphics ArrayFlatten is needed when you have arrays inside an array which is not the case for your second example.
    – Nasser Oct 19 '23 at 19:25
  • Great, thank you for the explanation! – ConfusedCabbage Oct 20 '23 at 07:02