MathGroup Archive 2005

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

Search the Archive

Re: How to "search" in a matrix?


Renan,

Use Position.

matr = {{a, b, 1}, {c, d, 2}, {e, f, 3}};

Position[matr, e]
{{3, 1}}

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: Renan [mailto:renan.birck at gmail.com]
To: mathgroup at smc.vnet.net


I have this matrix:

matr = {{a, b, 1}, {c, d, 2}, {e, f, 3}}

I'm trying to do a "search" in a matrix. The "real" matrix will contain
strings.
How to "search" for a given value in a matrix and return all lines that have
it?

'Select' seems to handle only lists - and this would require a
Flatten, probably making my code too complicated and maybe slow (the
real matrix will contain something like 100 elements - weather data).

Thanks.



  • Prev by Date: Exporting PNGs with transparent backgroud?
  • Next by Date: Re: How to "search" in a matrix?
  • Previous by thread: Re: How to "search" in a matrix?
  • Next by thread: Re: How to "search" in a matrix?