1
$\begingroup$

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

$\endgroup$
8
  • $\begingroup$ In light of the fact that N has reserved meaning in Mathematica, I request you to modify your post. $\endgroup$ Commented Oct 18, 2023 at 5:19
  • $\begingroup$ 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. $\endgroup$ Commented Oct 18, 2023 at 5:31
  • $\begingroup$ [ʼ] is not the same prime that Mathematica uses for differentiation [']. Mathematica can distinguish unicode characters, see mathematica.stackexchange.com/questions/11499/… $\endgroup$ Commented Oct 18, 2023 at 6:12
  • $\begingroup$ 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). $\endgroup$ Commented Oct 18, 2023 at 16:15
  • $\begingroup$ I've rewritten the question in a form that I believe is more convenient to answer. $\endgroup$ Commented Oct 19, 2023 at 1:04

1 Answer 1

2
$\begingroup$

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

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$ Commented Oct 19, 2023 at 7:40
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Oct 19, 2023 at 19:25
  • $\begingroup$ Great, thank you for the explanation! $\endgroup$ Commented Oct 20, 2023 at 7:02

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.