1、在某海域测得一些点(x,y)处的水深 z 由下表给出,船的吃水深度为 5 英尺,在矩形区域(75,200)*(-50,150)里的哪些地方船要避免进入。X 129 140 103.5 88 185.5 195 105Y 7.5 141.5 23 147 22.5 137.5 85.5Z 4 8 6 8 6 8 8X 157.5 107.5 77 81 162 162 117.5Y -6.5 -81 3 56.5 -66.5 84 -33.5Z 9 9 8 8 9 4 9(1) 输入插值基点数据;(2) 在矩形区域(75,200)*(-50,150)作二维三次插值法;(3) 做海底曲面图;(4)
2、 作出水深小于 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;xi=75:10:200;yi=-50:10:150;figure(1)z1i=griddata(x,y,z,xi,yi,nearest); % 最邻近插值surfc
3、(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);画图结果: