0
$\begingroup$

I have a mathematica function that returns a list of the form:

list1 = {
            {
                {a11,a12,a13},{a21,a22,a23},...
            },
            {
                {b11,b12,b13},{b21,b22,b23},...
            },
            ...
        }

And I want to create three lists of the form

newlist1 = {
               {a11,a21,...},
               {b11,b21,...},
               ...
           }

newlist2 = {
                 {a12,a22,...},
                 {b12,b22,...},
                 ...
           }


newlist3 = {
                 {a13,a23,...},
                 {b13,b23,...},
                 ...
           }
$\endgroup$
1
  • 1
    $\begingroup$ Either of Transpose[] or Flatten[] can do this. $\endgroup$ May 18, 2016 at 8:48

1 Answer 1

2
$\begingroup$
list1 = {{{a11, a12, a13}, {a21, a22, a23}}, {{b11, b12, b13}, {b21, b22, b23}}}    

{newlist10, newlist20, newlist30} = Transpose[list1, {2, 3, 1}]
newlist10 // Grid
newlist20 // Grid
newlist30 // Grid

{{{a11, b11}, {a21, b21}}, {{a12, b12}, {a22, b22}}, {{a13, b13}, {a23, b23}}}

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.