Anonymous User

# How would I put each matrix into a block matrix?

Anonymous User
Posted 9 years ago
1168 Views
|
3 Replies
|
1 Total Likes
|
 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}}
3 Replies
Sort By:
Posted 9 years ago
 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
Anonymous User
Anonymous User
Posted 9 years ago
 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}}
Posted 9 years ago
 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 givesBest wishes,Marco