Interpolating over a grid
2 ビュー (過去 30 日間)
古いコメントを表示
Hello. I have a grid of x and y coordinates and I would like to interpolate some z values over this grid. The grid constitues an area of ocean, and the z values, d_sea, constitutes sea depth values in metres. The dataset seadepth_002536 is a line of known seadepth values. I would like to know the sea depth values of the entire [x,y] grid. I have tried using interp2 but I am getting errors. Any help is appreciated. Thanks.
tykkelse_002536 = load('tykkelse_002536.txt');
seadepth_002536 = load('seafloor_depth_002536.txt');
v_sea = 1500; %p-wave velocity of water
v_sed = 2000; %p-wave velocity of sediment
x = tykkelse_002536(:,1);
y = tykkelse_002536(:,2);
d = tykkelse_002536(:,3);
d = d .* v_sed;
x_sea = seadepth_002536(:,1);
y_sea = seadepth_002536(:,2);
d_sea = seadepth_002536(:,3);
[Uxz_sea,ia,ic] = unique([x_sea d_sea],'rows');
x_sea = Uxz_sea(:,1);
d_sea = Uxz_sea(:,2);
d_sea = d_sea .* v_sea;
dx = 20;
x_ax=min(x):dx:max(x);
y_ax=min(y):dx:max(y);
[xx,yy]=meshgrid(x_ax,y_ax);
zii = interp2(x_sea,y_sea,d_sea,xx,yy);
0 件のコメント
採用された回答
Chunru
2021 年 11 月 7 日
Use scatteredInterpolant instead.
tykkelse_002536 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/792574/tykkelse_002536.txt');
seadepth_002536 = readmatrix('https://www.mathworks.com/matlabcentral/answers/uploaded_files/792579/seafloor_depth_002536.txt');
v_sea = 1500; %p-wave velocity of water
v_sed = 2000; %p-wave velocity of sediment
x = tykkelse_002536(:,1);
y = tykkelse_002536(:,2);
d = tykkelse_002536(:,3);
d = d .* v_sed;
x_sea = seadepth_002536(:,1);
y_sea = seadepth_002536(:,2);
d_sea = seadepth_002536(:,3);
[Uxz_sea,ia,ic] = unique([x_sea d_sea],'rows');
x_sea = Uxz_sea(:,1);
d_sea = Uxz_sea(:,2);
d_sea = d_sea .* v_sea;
dx = 20;
x_ax=min(x):dx:max(x);
y_ax=min(y):dx:max(y);
[xx,yy]=meshgrid(x_ax,y_ax);
% zii = interp2(x_sea,y_sea,d_sea,xx,yy);
f = scatteredInterpolant(x_sea, y_sea, d_sea);
zii = f(xx, yy);
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Interpolation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!