1、当我们有一些三维的数据,xyz都是矩阵的数据,可以描述数据的样貌,如下图所示:
x1=0:400:5600;
y1=0:400:4800;
z = [370,510,650,740,830,880,910,950,1430,1420,1380,1370,1350;
470,620,760,880,980,1060,1090,1190,1410,1430,1410,1390,1370;
550,730,880,1080,1180,1230,1270,1370,1460,1450,1430,1410,1390;
600,800,970,1130,1320,1390,1500,1500,1500,1480,1450,1430,1400;
670,850,1020,1250,1450,1500,1200,1200,1550,1500,1470,1440,1410;
690,870,1050,1280,1420,1500,1100,1100,1600,1550,1320,1140,960;
670,850,1020,1230,1400,1400,1350,1550,1550,1510,1280,1110,940;
620,780,830,1040,1300,900,1450,1600,1600,1430,1200,1050,880;
580,720,800,900,700,1100,1200,1550,1600,1300,1080,950,800;
450,650,700,500,900,1060,1150,1380,1600,1200,940,820,690;
400,500,300,700,850,950,1010,1070,1550,980,720,690,570;
300,200,500,780,840,870,880,900,1500,850,620,540,430;
100,300,550,750,380,900,1000,1050,1500,750,460,380,290;
150,350,420,650,780,930,1050,1150,1550,550,370,300,210;
250,320,350,550,750,950,1100,1200,1500,500,350,210,150];
[x,y]=meshgrid(x1,y1);
figure(1)
mesh(x,y,z')
2、由于数据采样点不够丰富,也就是数据点不多的时候,就像能否用更多的点,这样更多的点描述的样貌就更细腻。就需要插值,用更多的采样点去呈现图形。
3、用到interp2这个函数,增加的代码和图像如下:
[X,Y]=meshgrid(0:100:5600,0:100:4800);
Z=interp2(x,y,z',X,Y,'cubic');
figure(2)
mesh(X,Y,Z)
4、总结:
主要是interp2的用法,一样要看帮助,前面三个参数是原始的数据,中间两个参数是差值的位置点,最后一个应该是插值的方法。