MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: extracting column data from 2D Matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg23441] Re: [mg23412] extracting column data from 2D Matrix
  • From: "Mark Harder" <harderm at ucs.orst.edu>
  • Date: Wed, 10 May 2000 02:32:22 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Chris;
    You asked, first:
>
>How do I automate the process for the column Index without have to type it
>each time? That is perhaps something like the following I had in mind:
>

    I don't understand what @@@ is all about, even though its gotten a lot
of attention here lately, so I do without it:
First, define a funtion to get the columns using Range[] to generate the
list of column indices within Part ([[ ]]):

        selectCols[mtx_List, len_Integer, nSkip_Integer] :=
                mtx[[All, Range[1, len, nSkip] ]];

define a 5 by 10 matrix:

        mat = Array[m, {5, 10}];

& then

In[28]:=
cols = selectCols[mat, Dimensions[mat][[2]], 3]
Out[28]:=
{{m[1, 1], m[1, 4], m[1, 7], m[1, 10]},
  {m[2, 1], m[2, 4], m[2, 7], m[2, 10]},
  {m[3, 1], m[3, 4], m[3, 7], m[3, 10]},
  {m[4, 1], m[4, 4], m[4, 7], m[4, 10]},
  {m[5, 1], m[5, 4], m[5, 7], m[5, 10]}}


    Your second question
>
>Also I like to average each 10 consequitive rows. That is I have written a
>RowMean function that generate the column vector of the 1000 elements. How
>do I then insert after each 10 y column the columns that holds the average?
>So the matrix now grows from 101 colums to 111 colums (still 1000 rows) but
>the averaged columns need to be inserted at (12,22,33,...).
>

isn't really clear to me, but I think you want to average sets of
10 consecutive elements from each row and insert the means in the column
following each set.
I've spent some time trying to do this in good FunctionalProgramming style
without success, so
I'll just have to leave it to the others.

-mark harder
harderm at ucs.orst.edu




  • Prev by Date: Re: Symbols & Legend Fonts in MultipleListPlot...
  • Next by Date: Re: extracting column data from 2D Matrix
  • Previous by thread: extracting column data from 2D Matrix
  • Next by thread: Re: extracting column data from 2D Matrix