测量到不同坐标点的高度值,如何用matlab画三维图 ;
附上部分数据:A=[-210.6627-33391.11925.0273-221.3052-33387.74154.5969-210.9391-33393.00685.5...
附上部分数据:A=[-210.6627 -33391.1192 5.0273
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
x=A(:,1);
y=A(:,2);
z=A(:,3);
x y z分别代表横纵坐标和高度,用surf命令不对啊。。。。 展开
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
x=A(:,1);
y=A(:,2);
z=A(:,3);
x y z分别代表横纵坐标和高度,用surf命令不对啊。。。。 展开
3个回答
展开全部
A=[-210.6627 -33391.1192 5.0273
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
xData = A(:,1);
yData = A(:,2);
zData = A(:,3);
minx = min(xData);
maxx = max(xData);
miny = min(yData);
maxy = max(yData);
tx = linspace(minx,maxx)';
ty = linspace(miny,maxy);
[XI,YI] = meshgrid(tx,ty);
ZI = griddata(xData,yData,zData,XI,YI);
mesh(XI,YI,ZI), hold
plot3(xData,yData,zData,'o'), hold off
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
view( -53, 50 );
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
xData = A(:,1);
yData = A(:,2);
zData = A(:,3);
minx = min(xData);
maxx = max(xData);
miny = min(yData);
maxy = max(yData);
tx = linspace(minx,maxx)';
ty = linspace(miny,maxy);
[XI,YI] = meshgrid(tx,ty);
ZI = griddata(xData,yData,zData,XI,YI);
mesh(XI,YI,ZI), hold
plot3(xData,yData,zData,'o'), hold off
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
view( -53, 50 );
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
具体编程如下:
xData = A(:,1)
yData = A(:,2)
zData = A(:,3)
minx = min(xData)
maxx = max(xData)
miny = min(yData)
maxy = max(yData)
[XI,YI] = meshgrid(tx,ty)
ZI = griddata(xData,yData,zData,XI,YI)
mesh(XI,YI,ZI), hold
plot3(xData,yData,zData,'o'), hold off
xlabel( 'x' )
ylabel( 'y' )
zlabel( 'z' )
grid on
view( -53, 50 )
参考:http://hi.baidu.com/zzz700/blog/item/c4cdab8c6eb202af0e244461.html
xData = A(:,1)
yData = A(:,2)
zData = A(:,3)
minx = min(xData)
maxx = max(xData)
miny = min(yData)
maxy = max(yData)
[XI,YI] = meshgrid(tx,ty)
ZI = griddata(xData,yData,zData,XI,YI)
mesh(XI,YI,ZI), hold
plot3(xData,yData,zData,'o'), hold off
xlabel( 'x' )
ylabel( 'y' )
zlabel( 'z' )
grid on
view( -53, 50 )
参考:http://hi.baidu.com/zzz700/blog/item/c4cdab8c6eb202af0e244461.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
A=[-210.6627 -33391.1192 5.0273
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
xData = A(:,1);
yData = A(:,2);
zData = A(:,3);
fitresult = fit( [xData, yData], zData, 'linearinterp');
figure( 'Name', '三维图' );
plot( fitresult, [xData, yData], zData );
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
view( -53, 50 );
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
xData = A(:,1);
yData = A(:,2);
zData = A(:,3);
fitresult = fit( [xData, yData], zData, 'linearinterp');
figure( 'Name', '三维图' );
plot( fitresult, [xData, yData], zData );
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
view( -53, 50 );
追问
不对啊,运行结果:
??? Error using ==> fit>handleerr
XDATA must be a column vector.
Error in ==> fit at 86
errstr = handleerr('curvefit:fit:xDataMustBeColumnVector', ...
Error in ==> aa at 14
fitresult = fit( [xData, yData], zData, 'linearinterp');
求指教~
追答
以上代码在matlab2009a版以上均可运行。
试一试:
A=[-210.6627 -33391.1192 5.0273
-221.3052 -33387.7415 4.5969
-210.9391 -33393.0068 5.5647
-221.8901 -33390.7396 5.0077
-211.384 -33394.7093 5.6505
-222.6117 -33392.778 5.0554
-212.7074 -33397.5459 5.7381
-225.8973 -33397.5869 5.5587];
xData = A(:,1);
yData = A(:,2);
zData = A(:,3);
minx = min(xData);
maxx = max(xData);
miny = min(yData);
maxy = max(yData);
tx = linspace(minx,maxx)';
ty = linspace(miny,maxy);
[XI,YI] = meshgrid(tx,ty);
ZI = griddata(xData,yData,zData,XI,YI);
mesh(XI,YI,ZI), hold
plot3(xData,yData,zData,'o'), hold off
xlabel( 'x' );
ylabel( 'y' );
zlabel( 'z' );
grid on
view( -53, 50 );
参考资料: http://hi.baidu.com/zzz700/blog/item/c4cdab8c6eb202af0e244461.html
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询