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

ahmad Saad
ahmad Saad 2023년 10월 9일
i prefer to use 'for' loop instead ???
Dyuman Joshi
Dyuman Joshi 2023년 10월 9일
@ahmad Saad Why? For what reason?
Matt has provided an efficient and a fully working solution. Why not use it?
ahmad Saad
ahmad Saad 2023년 10월 9일
@Dyuman Joshi it seems that the two figures are not similar.
i think "for" loop is straight forward
Matt J
Matt J 2023년 10월 9일
편집: Matt J 2023년 10월 9일
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.
ahmad Saad
ahmad Saad 2023년 10월 9일
@Matt J deep thanks for your explaination

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2023년 10월 6일
편집: Matt J 2023년 10월 6일

0 개 추천

[lat,lon,vals]=readvars('dataset.txt');
LAT=min(lat):2.5:max(lat);
LON=min(lon):5:max(lon);
VALS=griddata(lat,lon,vals, LAT',LON);
Warning: Duplicate data points have been detected and removed - corresponding values have been averaged.
surf(LAT,LON,VALS)

추가 답변 (1개)

Matt J
Matt J 2023년 10월 6일

0 개 추천

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);

카테고리

도움말 센터File Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

질문:

2023년 10월 6일

댓글:

2023년 10월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by