Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Given a matrix, find position of first non-zero element in each

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99570] Re: Given a matrix, find position of first non-zero element in each
  • From: Peter Pein <petsie at dordos.net>
  • Date: Fri, 8 May 2009 00:15:47 -0400 (EDT)
  • References: <gtrl9k$242$1@smc.vnet.net> <gtudbp$inj$1@smc.vnet.net>

Jens-Peer Kuska schrieb:
> Hi,
> 
> Map[Min, Transpose /@
>    Split[Position[A, a_ /; a =!= 0, {2}, Heads -> False ],
>     First[#1] === First[#2] &], {2}]
> 
> ?
> 
> Regards
>    Jens
> 

I like this solution, because it "automagically" skips rows with zeros only.
But why not simply "Except[0]" instead of "a_/;a=!=0"?

Cheers,
Peter


  • Prev by Date: Re: problems with DSolve
  • Next by Date: Re: Help with an error with NonlinearModelFit,
  • Previous by thread: Re: Given a matrix, find position of first non-zero element in each
  • Next by thread: Re: Given a matrix, find position of first non-zero element in each