Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
6 Replies
|
5 Total Likes
View groups...
Share
Share this post:

[?] Transfer 4 D matrix into 2 D matrix?

Posted 8 years ago

I would like to transfer the matrix above into a 4 by 4 matrix with the same order as ATTACHMENT blow. Please do not hard code it. I would like to see some functions to help me to overcome this problem thank you

Attachments:
POSTED BY: Sheng Dai
6 Replies
ArrayFlatten[a]

or

Flatten[a, {{1, 3}, {2, 4}}]  (* list of list of dimensions to merge *)
POSTED BY: Sander Huisman

ArrayFlatten is nice. I under-use that function...

Thanks

Marco

POSTED BY: Marco Thiel

I rarely use it actually, I go with Flatten generally. I think Flatten has all the functionality of ArrayFlatten 'inside it'…

POSTED BY: Sander Huisman
POSTED BY: Marco Thiel

Hi Sheng Dai,

is this what you are looking for?

a = {{{{"a", "b"}, {"c", "d"}}, {{"e", "f"}, {"g", "h"}}}, {{{"i", "j"}, {"k", "l"}}, {{"m", "n"}, {"o", "p"}}}};
Partition[Flatten[Transpose /@ a], 4] // MatrixForm

Cheers,

Marco

POSTED BY: Marco Thiel
Posted 8 years ago

Thank you Marco, that is a great help. And thank you everyone.

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