Sorting and averaging Data

4 views (last 30 days)
Felix
Felix on 31 Jul 2018
Answered: dpb on 31 Jul 2018
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!

Accepted Answer

dpb
dpb on 31 Jul 2018
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.

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!