MathGroup Archive 2006

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

Search the Archive

Re: How to delete a row and a column in a matrix?


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


  • Prev by Date: Re: Inequalities
  • Next by Date: Re: How to delete a row and a column in a matrix?
  • Previous by thread: Re: How to delete a row and a column in a matrix?
  • Next by thread: Re: How to delete a row and a column in a matrix?