Message Boards Message Boards

1
|
3838 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

Extracting Columns from multi dimensional list

Hi, Suppose I have data like:

data = Table[{{Subscript[a, x, 1, 1], Subscript[a, x, 1, 2], 
    Subscript[a, x, 1, 3]}, {Subscript[b, x, 2, 1], Subscript[b, x, 2,
     2], Subscript[b, x, 2, 3]}}, {x, 1, 3}]

I get data equals like: enter image description here

Now suppose I wan't to get from all rows the first item in the first list and the third item in the second list like:

enter image description here

It can be done by using:

{data[[All, 1, 1]], data[[All, 2, 3]]}\[Transpose]

or

{#[[1, 1]], #[[2, 3]]} & /@ data

However I would expect to be able to use just one Function like Part,Extract but I can't figure a way to do that.. Something like data[[All,{{1,1},{2,3}}]] Any suggestions?

POSTED BY: l van Veen
In[63]:= Partition[Extract[ivv, Flatten[{{#, 1, 1}, {#, 2, 3}} & /@ Range[3], 1]], 2]
Out[63]= {{a[1, 1, 1], b[1, 2, 3]}, {a[2, 1, 1],  b[2, 2, 3]}, {a[3, 1, 1], b[3, 2, 3]}}
POSTED BY: Udo Krause
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