Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Deleting entire row and/or column

  • To: mathgroup at smc.vnet.net
  • Subject: [mg98247] Re: Deleting entire row and/or column
  • From: mike.honeychurch at gmail.com
  • Date: Fri, 3 Apr 2009 04:38:58 -0500 (EST)
  • References: <gr0ghk$950$1@smc.vnet.net>

On Apr 1, 2:50 pm, KFUPM <hussain.alqaht... at gmail.com> wrote:
> Dear all
>
> I have large matrices having entire rows and/or columns of zeros and I
> want to delete those zero rows and columns. My question, what is the
> best (most compact) command to use in Mathematica. Please note that
> the value of zero is the real zero i.e 0.0000 not just 0.
>
> Regards,

yourMatrix /. x_ /;x == 0 -> Sequence[]

or if that doesn't work then

yourMatrix /. x : (_Real | _Integer) /; N[x] == 0. -> Sequence[]

you could change this to Chop[x] is the values ->0 could be considered
zero.

Mike


  • Prev by Date: BarChart in v. 7
  • Next by Date: Re: Deleting entire row and/or column
  • Previous by thread: Re: Deleting entire row and/or column
  • Next by thread: Re: Deleting entire row and/or column