Re: Table extraction

• To: mathgroup at smc.vnet.net
• Subject: [mg19197] Re: [mg19141] Table extraction
• From: BobHanlon at aol.com
• Date: Tue, 10 Aug 1999 02:52:52 -0400
• Sender: owner-wri-mathgroup at wolfram.com

```Maurice,

mat = Array[a, {5, 4}];

As you indicated, extracting rows is straightforward.

mat[[3]]

{a[3, 1], a[3, 2], a[3, 3], a[3, 4]}

Part[mat, {1, 3}]

{{a[1, 1], a[1, 2], a[1, 3], a[1, 4]},
{a[3, 1], a[3, 2], a[3, 3], a[3, 4]}}

To extract columns, use Transpose

Transpose[{Transpose[mat][[3]]}]

{{a[1, 3]}, {a[2, 3]}, {a[3, 3]}, {a[4, 3]}, {a[5, 3]}}

Transpose[Part[Transpose[mat], {1, 3}]]

{{a[1, 1], a[1, 3]}, {a[2, 1], a[2, 3]}, {a[3, 1], a[3, 3]},
{a[4, 1], a[4, 3]}, {a[5, 1], a[5, 3]}}

Alternatively, you can use Column in the standard package DataManipulation

Needs["Statistics`DataManipulation`"]

Column[mat, 3]

{a[1, 3], a[2, 3], a[3, 3], a[4, 3], a[5, 3]}

Transpose[{%}]

{{a[1, 3]}, {a[2, 3]}, {a[3, 3]}, {a[4, 3]}, {a[5, 3]}}

Column[mat, {1, 3}]

{{a[1, 1], a[1, 3]}, {a[2, 1], a[2, 3]}, {a[3, 1], a[3, 3]},
{a[4, 1], a[4, 3]}, {a[5, 1], a[5, 3]}}

Bob Hanlon

In a message dated 8/6/99 5:29:34 AM, maurice at phas.ucalgary.ca writes:

>I am trying to extract a section of a table with not much luck....
>
>I have defined two tables (actually two arrays which are used to plot
>vectors with ListPlotVectorField) as follows:
>
>xyvector = Table[{0.,0.},{j,1,64},{i,1,320}];
>backvector = Table[{0.,0.},{j,1,16},{i,1,100}];
>
>I need to extract part of xyvector and place it into  backvector. I have
>tried to use Part. I can extract the j range correctly (rows), but I
>can't get the Part function to extract in the i range (columns).
>
>I tried using Part[xyvector,{2,3}] which extracts 2 rows but I cannot
>figute out how to extract the necessary columns
>

```

• Prev by Date: almost ok
• Next by Date: RE: Sort
• Previous by thread: Table extraction
• Next by thread: Re: Table extraction