Re: extracting elements from multi-dimensional arrays
- To: mathgroup at smc.vnet.net
- Subject: [mg61302] Re: extracting elements from multi-dimensional arrays
- From: bghiggins at ucdavis.edu
- Date: Fri, 14 Oct 2005 22:22:32 -0400 (EDT)
- References: <dio1v0$t01$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Dan, try the following: In[37]:= lst=Table[Random[Real,{1,15}],{5},{3}] Out[37]= {{5.53554,11.6058,9.73763},{3.45237,7.84251,4.92252},{ 3.30427,13.1812,3.12078},{10.7528,14.8427,12.1167},{ 2.42761,13.2536,8.29897}} In[39]:= lst /. {x_Real /; x < 6 || x > 12, y_Real, z_Real} -> {y, z} /. {x___Real, y_Real /; y < 4 || y > 12, z_Real} -> {x, z} Out[39]= {{11.6058,9.73763},{7.84251,4.92252},{3.12078},{10.7528,12.1167},{8.29897}} or if you want to have a tag for those elements deleted you can use In[41]:= lst /. {x_Real /; x < 6 || x > 12, y_Real, z_Real} -> {0, y, z} /. {x___, y_Real /; y < 4 || y > 12, z_Real} -> {x, 0, z} Out[41]= {{0,11.6058,9.73763},{0,7.84251,4.92252},{ 0,0,3.12078},{10.7528,0,12.1167},{0,0,8.29897}} Cheers, Brian contact at dantimatter.com wrote: > Hello all, > > I have an array of the form: > > list={{a1,b1,c1},{a2,b2,c2}...} > > I'd like to get rid of elements of list based on criteria that apply to > the a's, b's and c's separately. For example, I'd like to keep the > elements of list that have the following properties: > > m < a < n > p < b < q > > I know there's an easy way to do this, but I can't figure it out. Any > suggestions? > > Thanks! > dan