MathGroup Archive 2004

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

Search the Archive

Re: Matrix Element Extraction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg46637] Re: Matrix Element Extraction
  • From: bobhanlon at aol.com (Bob Hanlon)
  • Date: Thu, 26 Feb 2004 17:53:25 -0500 (EST)
  • References: <c1irc0$6bn$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Select[Position[mat, _Integer, 2], 
  #[[1]] == Length[mat] ||
      #[[2]] == Length[mat[[1]]] &]


Bob Hanlon

In article <c1irc0$6bn$1 at smc.vnet.net>, "Curt Fischer" <crf3 at po.cwru.edu>
wrote:

<< In a matrix, I want to find the positions of all the integer elements in the
rightmost column or the bottom row.

In[1]:=
mat={{1,2,1},{4,5,6},{7,8,-Infinity}}

Out[1]=
{{1,2,1},{4,5,6},{7,8,-Infinity}}

In[2]:=
Position[Map[((MemberQ[Union[Flatten[{mat[[Length[mat]]],
                mat[[All,Dimensions[mat][[
                      2]] ]]}]],#])&&(#!=-Infinity))&,mat,{2}],True]

Out[2]=
{{1,1},{1,3},{2,3},{3,1},{3,2}}

This _mostly_ does what I want, but took me forever to think of.  I'm
convinced there must be an easier way...

Especially, is there an easy way to keep the point {1,1} from appearing on
this
list, other than using a replacement rule and an If[] command?  ({1,1} is
not a position in the bottom row or right most column, so I don't want this
point returned.)


  • Prev by Date: Re: Question about Integrate and If
  • Next by Date: Re: Saving Kernel Status
  • Previous by thread: Re: Matrix Element Extraction
  • Next by thread: Re: Matrix Element Extraction