作业帮 > 综合 > 作业

知道点的坐标,如何用MATLAB显示3D图形

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/13 16:01:28
知道点的坐标,如何用MATLAB显示3D图形
现在我已经求出一个物体上一些点的XYZ方向的坐标,想用MATLAB将物体的3D图还原出来
知道点的坐标,如何用MATLAB显示3D图形
举例说明:
已知3维点坐标(a,b,c)无序排列.
a = [9,8.8,5.8,9.8,6.4,1.2,2.6,5.2,6.6,2.2,2.8,10,4,4.8,2.2,6,1.8,5,1.6,6,1,6.8,4.6,4,3.4,5.6,5,8.4,5.2,5.6,2.8,6.2,6.4,7,6.2,8,2.4,8.6,10,7,2,6.4,2.2,9.6,7.8,9,2.4,5.2,4,3.6];
b = [1.8,9.4,4.4,2,2.6,1.6,4.4,5.6,2.8,4.8,7.8,5.8,2.6,6.4,7.6,1.8,3,1,8.8,5.8,8.4,6.6,1.4,1.2,2.6,5.2,9.6,3.4,5.4,8.8,4,7.4,5.4,2.8,7.8,2.2,5.8,6.6,8.6,4.2,7,1,7.6,7.2,2.2,2.2,6.2,8.2,9.6,7.4];
c = [1.0366,-0.7615,-1.0177,0.8882,2.0242,2.3615,-2.7601,-0.794,1.6202,-2.5808,1.0549,-1.7683,0.3774,0.3206,1.3473,2.9079,0.055,1.9666,1.1406,0.031,2.2495,1.4925,1.8587,1.2104,0.0642,-0.9913,-0.065,-1.0304,-1.077,1.9454,-2.4558,2.794,-0.5523,1.4239,2.9936,1.4715,-1.6666,-0.0556,0.6297,-0.9892,0.8978,2.6761,1.3473,0.6026,1.6709,0.7059,-0.9036,2.35,-1.0023,0.9007];
x = linspace(min(a)-1,max(a)+1,40);
y = linspace(min(b)-1,max(b)+1,40);
[X,Y] = meshgrid(x,y);%构造新格点
Z = griddata(a,b,c,X,Y,'cubic');%插值计算新格点的函数值
mesh(X,Y,Z);hold on
plot3(a,b,c,'r.','MarkerSize',20);