how to bin data
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ahmad Saad
am 6 Okt. 2023
Kommentiert: ahmad Saad
am 9 Okt. 2023
i have (attahed) dataset of 3 cols : (1st for lat. ,2nd for long., and the 3rd for datavalues).
i need to bin these data in a grid of lat(2.5) x long(5) degrees.
then plot the results with surf function over the coressponding map location ?
5 Kommentare
Matt J
am 9 Okt. 2023
Bearbeitet: Matt J
am 9 Okt. 2023
it seems that the two figures are not similar.
Which two figures? The figures in my 2 answers are different because they use different regridding algorithms. Both of them can be implemented using a for-loop, but how would that help you decide between them? It won't change the surfaces.
Akzeptierte Antwort
Weitere Antworten (1)
Matt J
am 6 Okt. 2023
Or perhaps,
[lat,lon,vals]=readvars('dataset.txt');
LAT=min(lat):2.5:max(lat);
LON=min(lon):5:max(lon);
G=findgroups(discretize(lat,LAT), discretize(lon,LON));
VALS=splitapply(@sum,vals,G)./splitapply(@numel,vals,G);
VALS=reshape(VALS, numel(LAT)-1,[]);
LAT=conv(LAT,[1,1]/2,'valid');
LON=conv(LON,[1,1]/2,'valid');
surf(LAT,LON,VALS);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!