I have a nested matrix n
:
n = {{a, b}, {c, d}}
a = {{0, t, q, dh}, {0, 1, 0, th}, {1, 1, 0, sh}}
b = {{0, t, q, dh}, {1, 0, 0, th}, {1, 0, 0, sh}}
c = {{0, t, q, dh}, {0, 1, 0, th}, {1, 0, 0, sh}}
d = {{0, t, q, dh}, {0, 0, 0, th}, {0, 1, 0, sh}}
With thanks to Nasser add column and Andy and Mike most efficient for their questions and answers, we can add a vector m = {rr, kk}
to this nested matrix as a column, for example:
pp = Transpose[Insert[Transpose[n], Flatten@m, 1]]
or
pp=Join[List /@ m, n, 2] // MatrixForm
Finally, after running the above lines we have pp
as:
{{rr, {{0, t, q, dh}, {0, 1, 0, th}, {1, 1, 0, sh}},
{{0, t, q, dh}, {1, 0, 0, th}, {1, 0, 0, sh}}},
{kk, {{0, t, q, dh}, {0, 1,0, th}, {1, 0, 0, sh}},
{{0, t, q, dh}, {0, 0, 0, th}, {0, 1, 0,sh}}}}
and pp/MatrixForm
as:
The result is correct but I wanted to obtain an obvious and clarified figure of pp/MatrixForm
same as :
Are there any possibility for obtaining the last form instead of the first form for pp/MatrixForm
.
MatrixForm[MapAt[MatrixForm, #, {2 ;;}] & /@ pp]
? $\endgroup$ – kglr Jun 27 '14 at 4:36MapAt
which should work regardless of the numbers of rows/columns. $\endgroup$ – kglr Jun 27 '14 at 4:52