Re: how to pick out alternating columns and rows in a matrix?
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg567] Re: [mg551] how to pick out alternating columns and rows in a matrix?
- From: bob at zim.uoregon.edu (Robert Zimmerman)
- Date: Sat, 18 Mar 95 18:46:59 -0800
Reply to mg551
Might not be more elegant but here is another solution,
mat = Array[a,{6,6}];
( mat//Flatten)//.
{a[x_ ,y_?EvenQ ] ->0, a[x_?EvenQ ,y_ ] ->0}//.
{ head___ ,0, tail___ } :> {head, tail}//
Partition[#,3]& //MatrixForm
a[1, 1] a[1, 3] a[1, 5]
a[3, 1] a[3, 3] a[3, 5]
a[5, 1] a[5, 3] a[5, 5]
Robert L. Zimmerman
Institute of Theoretical Science
University of Oregon
Eugene Oregon 97403