how to grid data

7 次查看(过去 30 天)
ahmad Saad
ahmad Saad 2023-10-17
评论: ahmad Saad 2023-10-17
Hi;
I have the attached data:
Col1: time,
Col2: lat,
Col3: long,
Col4: obs
I need to grid these data (2.5 lat x 5 long).
My trial:
clear all;
load('data.mat')
x=data(:,3);
LON=-50:5:50;
y= data (:,2);
LAT=-50:2.5:50;
z= data(:,4);
[X,Y] = meshgrid(LAT, LON);
Z = griddata(x,y,z,X,Y,'cubic');
Warning: Duplicate x-y data points detected: using average values for duplicate points.
figure
contourf(X,Y,Z);
grid on
ylim([-20 40])
xlim([-20 50])
shading('interp')
view(0,90)
colormap('jet')
colorbar
xlabel('LONG')
ylabel('LAT')
  5 个评论
Walter Roberson
Walter Roberson 2023-10-17
And you already did that.
However, you have duplicate points with different Z values. How do you want to handle those points? griddata() handles the situation by taking mean() of the z at the locations with duplicates.
ahmad Saad
ahmad Saad 2023-10-17
Actully, i am not sure if my code is correct or not

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interpolation of 2-D Selections in 3-D Grids 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by