Re: How to delete a row and a column in a matrix?
- To: mathgroup at smc.vnet.net
- Subject: [mg69706] Re: How to delete a row and a column in a matrix?
- From: dimmechan at yahoo.com
- Date: Thu, 21 Sep 2006 07:29:51 -0400 (EDT)
- References: <eeqqlr$onu$1@smc.vnet.net>
Hi.
The following user defined function does what you want.
For clarity I have converted everything ro InputForm.
Clear["Global`*"]
delColRow[(x_)?MatrixQ, (n_Integer)?Positive, (m_Integer)?Positive] :=
(Delete[#1, m] & ) /@
Delete[x, n]
Example
mat = Array[#1 + 2*#2 & , {4, 4}]
{{3, 5, 7, 9}, {4, 6, 8, 10}, {5, 7, 9, 11}, {6, 8, 10, 12}}
delColRow[mat, 2, 2]
{{3, 7, 9}, {5, 9, 11}, {6, 10, 12}}
delColRow[mat, 3, 2]
{{3, 7, 9}, {4, 8, 10}, {6, 10, 12}}
Cheers
Dimitris