Average all variable in the same Longitude and Latitude for Excel

1 view (last 30 days)
Hello, Please help me to resolve my problem. I want to make a script for my study requirement.
I have an excel file (.xlsx). Which have 275653x6 matrix (row x column)
The column is :
1. Longitude
2. Latitude
3. variable a
4. variable b
5. variable c
6. variable d
I want to be able to average all variable in the same latitude and longitude (Longitude and Latitude dont be averaged) and make the result into matrix/table/excel. Please help me.
Thank You

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 2 May 2016
Edited: Andrei Bobrov on 2 May 2016
xlsxfile.xlsx - your xlsx-file with tible with size [275653x6 ]
A = xlsread('xlsxfile.xlsx');
[a,~,c] = unique(A(:,1:2),'rows');
[x,y] = ndgrid(c,1:size(A,2)-2);
V = A(:,3:end);
out = [a, accumarray([x(:),y(:)],V(:),[],@mean)];
  1 Comment
Siregar
Siregar on 3 May 2016
thank you so much for the reply Mr. Andrei. this is really help me. and its work :)
i want to ask one question more: i want to average 3 variable (2,3,4) in the same one of variable (example:depth), latitude and longitude (depth, Longitude and Latitude dont be averaged). what should ive change in that script?
Thank you for your quick responses :D

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!