Re: partition of 2D arrray
- To: mathgroup at smc.vnet.net
- Subject: [mg49178] Re: partition of 2D arrray
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Tue, 6 Jul 2004 03:33:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
On 7/5/04 at 4:54 AM, ravi at crest.ernet.in (Ravinder Kumar B.) wrote: >Dear Friends, I have a list of 2D data of the following form: >{{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}; In MatrixForm it >is 4x4 matrix. How do I extract the fisrt two column of the data >from the above matrix. i.e., {{1,2},{5,6},{9,10},{13,14}} In[1]:= a = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; In[2]:= a[[All,{1, 2}]] Out[2]= {{1, 2}, {5, 6}, {9, 10}, {13, 14}} In[3]:= (Take[#1, 2] & ) /@ a Out[3]= {{1, 2}, {5, 6}, {9, 10}, {13, 14}} And there are other ways using the functions in the package Statistics`DataManipulation` or the functions in the package LinearAlgebra`MatrixManipulation` -- To reply via email subtract one hundred and four