MathGroup Archive 2005

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

Search the Archive

Re: More help on sorting out a large list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58384] Re: More help on sorting out a large list
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 30 Jun 2005 04:37:20 -0400 (EDT)
  • References: <d9t15f$j7b$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,
We can solve your problem by using Split to split the rows into "equal" 
rows and then we replace every batch of equal rows by an "avarage".
The split command will look like (assuming your data-matrix is in data, 
and x is the 5., y the 6. row):
tmp= Split[data,#1[[{5,6}]]==#2[[{5,6}]]&]

To get the avarage, we need a function that gives the indices of the 
rows to take the avarage from. That is, for an even number: {n/2,n/2+1} 
for an odd number:{(1+n)/2,(1+n)/2}

f1[n_]:= If[EvenQ[n],{n/2,n/2+1},{(n+1)/2,(n+1)/2}];
with this we finally get:

Mean[ Take[#,f1[Length[#]]]]& /@ tmp

sincerely, Daniel

tornado78 wrote:
> Ok here's a problem I've been trying to figure out for awhile.  I have a large XYZ sorted matrix and what i need is to look at two columns x,y and and if it is a unique point keep the row, if there are multiple rows with same x,y pair i need to remove all of them and leave only the middle Z row or the average of the middle two Z rows
> 
> for example
> 
>              x  y  z
> {1, 6, 4, 8, 4, 5, 8, 3} drop
> {1, 3, 5, 8, 4, 5, 3, 3}--take
> {5, 3, 6, 8, 4, 5, 6, 3} drop
> {4, 5, 3, 4, 5, 6, 1, 0}drop
> {2, 5, 4, 3, 5, 6, 9, 1}\
> {1, 2, 5, 4, 5, 6, 7, 8} -take average
> {3, 5, 6, 3, 5, 6, 6, 4}drop 
> {5, 3, 5, 2, 7, 8, 2, 5}----take
> 
> 
> thanks for any help
> 


  • Prev by Date: Re: More help on sorting out a large list
  • Next by Date: Re: Re: ListInterpolation
  • Previous by thread: Re: More help on sorting out a large list
  • Next by thread: New Visualization - Earthquake data