Average all variable in the same Longitude and Latitude for Excel
1 view (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
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)];
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!