Adding duplicate values based on table variable names

I have a large set of tables, separated by date, with geographical coordinates (X_LOC and Y_LOC) and user defined fields to visualize ('CustInt', for example).
My mission is to combine those tables, and if exact X_LOC and Y_LOC duplicates exist, add the values together. Though, this may not be a necessity as the precision of the coordinates is in the 0.000001 range. So for example:
File 1: File 2:
X_LOC Y_LOC CustInt {... other fields} X_LOC Y_LOC CustInt
12.100 13.100 20 ... 12.100 13.11 20
Combined:
X_LOC Y_LOC CustInt
12.100 13.100 20
12.100 13.11 20
The only thing to keep in mind is that the files are large (thousands * 31 variables) and my idea of iterating through duplicates could increase complexity exponentionally.
Would a simple outerjoin() be helpful? Is there any way of combining only columns that you want for two tables?
Thanks in advance.

4 comentarios

In my opinion using the "ismember" function mybe helpful to determine the matching rows in file1 and file2 and adding the missing entries.
[file1, file2] = ismember(file1.X_LOC, file2.X_LOC);
file1(indx1,'X_LOC') = file2(indx2(indx1),'X_LOC');
Then you can remove unwanted columns.
Stephen23
Stephen23 el 9 de Feb. de 2020
Editada: Stephen23 el 9 de Feb. de 2020
@Behzad Navidi: your code overwrites file1 and file2, and does not define indx1 nor indx2. Did you mean?:
[indx1, indx2] = ismember(file1.X_LOC, file2.X_LOC);
BN
BN el 9 de Feb. de 2020
Editada: BN el 9 de Feb. de 2020
Oh, I'm sorry my bad. Yes, I thought he could think about ismember. Thank you.
ismembertol seems more realistic than ismember for this purpose

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Data Distribution Plots en Centro de ayuda y File Exchange.

Preguntada:

el 11 de Mayo de 2019

Comentada:

el 9 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by