Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1995

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

Search the Archive

RE: how to pick out alternating columns and rows in a matrix

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg619] RE: how to pick out alternating columns and rows in a matrix
  • From: Xah Y Lee <xyl10060 at fhda.edu>
  • Date: Thu, 30 Mar 1995 04:30:09 -0800 (PST)

Richard Q. Chen <chen at fractal.eng.yale.edu> wrote:

> Suppose I have a matrix of even dimensions, I would like
>to form a matrix consisting of only the odd rows and columns of the
>matrix.

I come late on this.
After few hours of mma hack, I found an elegant one-liner.

-------------
myList = Array[a,{30,20}];

Map[ First, Partition[ myList,{2,2}],{2,3}];
-------------

The drawback of this is that the input matrix must have length even. If 
odd, the last one will be dropped. There are ways to overcome this but 
that'll be another hack. The advantage is that it can be generalized, and 
exteremely fast.

I might do a summary of all the solutions after I studied them.

 Xah  (of the _Venus & Xah Love Factory_ fame)   74631.731 at compuserve.com
 Quote of the day:
  To go beyond infinity, you need love.      --Venus


  • Prev by Date: Transformation of homogeneous ODE
  • Next by Date: Compact way to store BC's
  • Previous by thread: Transformation of homogeneous ODE
  • Next by thread: Re: RE: how to pick out alternating columns and rows in a matrix