MATLAB: Sorting and averaging Data

datagpssorting

Hey everyone,
I have a the following Problem: I have a table with the structure of the form
GPS_LONG|GPS_LAT|A|B
with lots of data points. What I want to to is to identify the 2D-Data points (GPS_LONG,GPS_LAT) which are equal. If there exists such points, I want to build the mean value over A and B and, so that I only have one unique data point (GPS_LONG,GPS_LAT) left. I know that this could basically done with two loops over the array, comparing each point with all other ones. Since I only have limited computing power and lots of data, I need a smart and efficient way to do it!
Thanks in advance!

Best Answer

Are the position data points exact duplicates? If so,
[g,tGPS]=findgroups(t.GPS_LONG,t.GPS_LAT); % groups table
tGPS.A=splitapply(@mean,A,g); % add means to the
tGPSB.=splitapply(@mean,B,g); % groups table
If you have positions that are close but not identical that want to consider as equals, build the indication vector of which with ismembertol as a new grouping variable.