Matlab之二维插值:估测海底某曲面地形
1
2
3
4
5
6
7
8
9
10
% 2维插值示例:估测海底某曲面地形
x = [129,140,103.5,88,185.5,195,105,157.5,107.5,77,81,162,162,117.5];
y = [7.5,141.5,23,147,22.5,137.5,85.5,-6.5,-81,3,56.5,-66.5,84,-33.5];
z = -[4,8,6,8,6,8,8,9,9,8,8,0,4,9];
xmm = minmax(x);
ymm = minmax(y);
xi = xmm(1):2.5:xmm(2);
yi = ymm(1):2.5:ymm(2);
z_interp = griddata(x,y,z,xi,yi','V4'); %griddata插值同interp2,但是对数据要求不严格
surf(xi,yi,z_interp);

输出结果

ans

ans

PS:深度大于0的部分应手动舍弃,边值区域的二维插值会遇到问题。

文章作者: GeYu
文章链接: https://nuistgy.github.io/2020/02/21/Matlab数模(2)/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Yu's Blog