Info
此问题已关闭。 请重新打开它进行编辑或回答。
facing problem to plotting surface plot from imported data
1 次查看(过去 30 天)
显示 更早的评论
hi all, i m facing a problem in ploting the surface in 3 d. i have 3 data which i import from listing file having x coordinate in first column, y coordinate in second column nd the displacement values corresponding to that (x,y) coordinate in third column. now how i plot these values using surf() function. when i use these data directly it gives an error that z must be matrix . please help me to solve this.
my coding is
node=coordinate(:,1);
x=coordinate(:,2);
y=coordinate(:,3);
ux=uxdata(:,2);
surf(x,y,ux);
0 个评论
回答(2 个)
Jonathan Epperl
2012-10-14
编辑:Jonathan Epperl
2012-10-14
As a quick workaround, use
plot3(x,y,ux,'.');
If you want to use surf or mesh because it looks prettier, then here is what your problem is: surf(X,Y,Z) needs matrices as input because it creates a tile between
[X(i,j) Y(i,j) Z(i,j)]
[X(i+1,j) Y(i+1,j) Z(i+1,j)]
[X(i,j+1) Y(i,j+1) Z(i,j+1)]
[X(i+1,j+1) Y(i+1,j+1) Z(i+1,j+1)]
See what the problem with your data is? Matlab has no idea which nodes to connect. So let's hope and assume that your data is in a somewhat useful form anyway, namely
x = [1 2 3 1 2 3 1 2 3];
y = [1 1 1 2 2 2 3 3 3];
% ux = [ux(1,1) ux(2,1) etc..]
ux = [pi 3 0 .3 10 -3 -1 .1 pi];
Then, you need to reshape your data into matrices so that adjacent indices work as described above: X = reshape(x,3,3); Y = reshape(y,3,3); U = reshape(ux,3,3); surf(X,Y,U)
1 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!