Re: how to apply Position repeatedly without a loop?
- To: mathgroup at smc.vnet.net
- Subject: [mg118657] Re: how to apply Position repeatedly without a loop?
- From: Alexei Boulbitch <alexei.boulbitch at iee.lu>
- Date: Fri, 6 May 2011 07:22:56 -0400 (EDT)
What about this:
A = {{1, 2, 3}, {3, 4, 5}, {6, 7, 8}};
elements = {3, 6};
Position[A, #]& /@ elements
{{{1, 3}, {2, 1}}, {{3, 1}}}
??
Have fun, Alexei
i have matrix A and wanted to find the Positions in this matrix of
some elements which listed in some another vector.
how to use Position to do it without a loop?
I tried this:
In[192]:= A={{1,2,3},
{3,4,5},
{6,7,8}};
elements={3,6};
Position[A,r[[1]]]
Out[194]= {{1,1}}
Position[A,r[[2]]]
Out[197]= {{1,2}}
but I want to do something like
Position[A,r]
but this does not work.
I tried Map, Thread, etc.. but could not get it to work. not sure what
the syntax is.
thanks for help
steve
--
Alexei Boulbitch, Dr. habil.
Senior Scientist
Material Development
IEE S.A.
ZAE Weiergewan
11, rue Edmond Reuter
L-5326 CONTERN
Luxembourg
Tel: +352 2454 2566
Fax: +352 2454 3566
Mobile: +49 (0) 151 52 40 66 44
e-mail: alexei.boulbitch at iee.lu
www.iee.lu
--
This e-mail may contain trade secrets or privileged, undisclosed or
otherwise confidential information. If you are not the intended
recipient and have received this e-mail in error, you are hereby
notified that any review, copying or distribution of it is strictly
prohibited. Please inform us immediately and destroy the original
transmittal from your system. Thank you for your co-operation.