在某海域测得一些点(x,y)处的水深z由下表给出,船的吃水深度为5英尺,在矩形区域(75,200)*(-50,150)里的哪些地方船要避免进入。
X | 129 | 140 | 103.5 | 88 | 185.5 | 195 | 105 |
Y | 7.5 | 141.5 | 23 | 147 | 22.5 | 137.5 | 85.5 |
Z | 4 | 8 | 6 | 8 | 6 | 8 | 8 |
X | 157.5 | 107.5 | 77 | 81 | 162 | 162 | 117.5 |
Y | -6.5 | -81 | 3 | 56.5 | -66.5 | 84 | -33.5 |
Z | 9 | 9 | 8 | 8 | 9 | 4 | 9 |
(1) 输入插值基点数据;
(2) 在矩形区域(75,200)*(-50,150)作二维三次插值法;
(3) 做海底曲面图;
(4) 作出水深小于5的海域范围,即z=5的等高线。
解:
解答:
Matlab程序:
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,-9,-4,-9];
matlab等高线数据提取xi=75:10:200;
yi=-50:10:150;
figure(1)
z1i=griddata(x,y,z,xi,yi','nearest'); % 最邻近插值
surfc(xi,yi,z1i)
xlabel('X'),ylabel('Y'),zlabel('Z')
figure(2)
z2i=griddata(x,y,z,xi,yi'); % 双线性插值surfc(xi,yi,z2i)
xlabel('X'),ylabel('Y'),zlabel('Z')
figure(3)
z3i=griddata(x,y,z,xi,yi','cubic'); % 双三次插值
surfc(xi,yi,z3i)
xlabel('X'),ylabel('Y'),zlabel('Z')
figure(4)
subplot(1,3,1),contour(xi,yi,z1i,4,'b');
subplot(1,3,2),contour(xi,yi,z2i,4,'r');
subplot(1,3,3),contour(xi,yi,z3i,4,'g');
figure(5) % z=5的等高线
contour(xi,yi,z3i,7,'r');
clabel(z3i,5);
画图结果:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论