e = {{1}}
a {{2, 2}, {2, 2}}
b = {{3, 3, 3}, {3, 3, 3}, {3, 3, 3}}
c = {{4, 4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}}
d = {{5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5,
5}, {5, 5, 5, 5, 5}}
Hi Bob,
not sure if this is what you want. First we take your matrices:
e = {{1}};
a = {{2, 2}, {2, 2}} ; b = {{3, 3, 3}, {3, 3, 3}, {3, 3, 3}};
c = {{4,4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}} ;
d = {{5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5,5, 5, 5}};
And then we do this:
list = {e, a, b, c, d}; matr = ConstantArray[0, {5, 5}]; For[i = 1, i <= 5, i++, matr[[i, i]] = list[[i]]];
ArrayFlatten[matr] // MatrixForm
which gives
Best wishes,
Marco
interesting my output gave me {{e,0,0,0,0},{0,a,0,0,0},{0,0,b,0,0},{0,0,0,c,0},{0,0,0,0,d}}
That is if you have not executed the first bit:
e = {{1}};
a = {{2, 2}, {2, 2}} ; b = {{3, 3, 3}, {3, 3, 3}, {3, 3, 3}};
c = {{4,4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}, {4, 4, 4, 4}} ;
d = {{5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5, 5, 5, 5}, {5, 5,5, 5, 5}};
If you execute this and then
list = {e, a, b, c, d}; matr = ConstantArray[0, {5, 5}]; For[i = 1, i <= 5, i++, matr[[i, i]] = list[[i]]];
ArrayFlatten[matr] // MatrixForm
it will work.
Cheers,
Marco
