Skip to main content
added 183 characters in body
Source Link
Daniel Huber
  • 56.4k
  • 2
  • 24
  • 66

First define the ui and ji using helper functions:

u[i_] := {Subscript[u, i, 1], Subscript[u, i, 2], Subscript[u, i, 3]}
{u1, u2, u3} = u /@ {1, 2, 3};
j[i_] := Table[Subscript[j, i, i1, i2], {i1, 3}, {i2, 3}];
{j1, j2, j3} = j /@ {1, 2, 3};

Now it is easy to create the final matrix:

mat={{u1 . j1 . u1, 0, 0}, {0, u2 . j2 . u2, 0}, {0, 0, u3 . j3 . u3}};
mat // MatrixForm

enter image description here

Addendum

If you want to create the matrix automatically instead by hand, you may write:

DiagonalMatrix[
 MapThread[#1 . #2 . #1 &, {{u1, u2, u3}, {j1, j2, j3}}]] 

First define the ui and ji using helper functions:

u[i_] := {Subscript[u, i, 1], Subscript[u, i, 2], Subscript[u, i, 3]}
{u1, u2, u3} = u /@ {1, 2, 3};
j[i_] := Table[Subscript[j, i, i1, i2], {i1, 3}, {i2, 3}];
{j1, j2, j3} = j /@ {1, 2, 3};

Now it is easy to create the final matrix:

mat={{u1 . j1 . u1, 0, 0}, {0, u2 . j2 . u2, 0}, {0, 0, u3 . j3 . u3}};
mat // MatrixForm

enter image description here

First define the ui and ji using helper functions:

u[i_] := {Subscript[u, i, 1], Subscript[u, i, 2], Subscript[u, i, 3]}
{u1, u2, u3} = u /@ {1, 2, 3};
j[i_] := Table[Subscript[j, i, i1, i2], {i1, 3}, {i2, 3}];
{j1, j2, j3} = j /@ {1, 2, 3};

Now it is easy to create the final matrix:

mat={{u1 . j1 . u1, 0, 0}, {0, u2 . j2 . u2, 0}, {0, 0, u3 . j3 . u3}};
mat // MatrixForm

enter image description here

Addendum

If you want to create the matrix automatically instead by hand, you may write:

DiagonalMatrix[
 MapThread[#1 . #2 . #1 &, {{u1, u2, u3}, {j1, j2, j3}}]] 
Source Link
Daniel Huber
  • 56.4k
  • 2
  • 24
  • 66

First define the ui and ji using helper functions:

u[i_] := {Subscript[u, i, 1], Subscript[u, i, 2], Subscript[u, i, 3]}
{u1, u2, u3} = u /@ {1, 2, 3};
j[i_] := Table[Subscript[j, i, i1, i2], {i1, 3}, {i2, 3}];
{j1, j2, j3} = j /@ {1, 2, 3};

Now it is easy to create the final matrix:

mat={{u1 . j1 . u1, 0, 0}, {0, u2 . j2 . u2, 0}, {0, 0, u3 . j3 . u3}};
mat // MatrixForm

enter image description here