Message Boards Message Boards

0
|
1261 Views
|
3 Replies
|
1 Total Likes
View groups...
Share
Share this post:
GROUPS:

How would I put each matrix into a block matrix?

Anonymous User
Anonymous User
Posted 10 years ago

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}}

POSTED BY: Anonymous User
3 Replies

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

POSTED BY: Marco Thiel
Anonymous User
Anonymous User
Posted 10 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 BY: Anonymous User

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

enter image description here

Best wishes,

Marco

POSTED BY: Marco Thiel
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract