3D plot help

1 次查看(过去 30 天)
laurent jalabert
laurent jalabert 2018-7-30
Dear all, I am sorry for this basic question, but even I have some experience with matlab, I am not able to understand why I cannot display a 3D graph with a set of data X,Y,Z below.
X = (1:1:5)'; % column vector of Param 1
Y = (1:1:10)'; % column vector of Param 2
Z = sin((1:1:50))'; % example of 1D data, but in real case it is point by point (not a function like sin(x,y), cos or any).
shape_Z = reshape(Z, length(X), length(Y));% in 2D representation
I have 1D x-axis parameter, 1D y-axis parameter, and Z is also 1D listing the associated data. In fact Z is reshaped to shape_Z in 2D to have a better understanding of the value for each (X,Y) parameters, as it is not intuitive with Z in 1D.
  2 个评论
madhan ravi
madhan ravi 2018-7-30
编辑:madhan ravi 2018-7-30
It’s because they are independent of each other, it means it’s three dimensional arguments in 4 dimensional space and matlab is only capable of 3 dimensional space.
laurent jalabert
laurent jalabert 2018-7-30
... yes, you are right but please try this :
X = (-1:1:5)'; sx = size(X)
Y = (-1:1:10)'; sy = size(Y)
Z = sin((0:1:sx(1)*sy(1)-1))'; size(Z)
shape_Z = reshape(Z, length(X), length(Y)); size(shape_Z)
surf(shape_Z)
alpha 0.5

请先登录,再进行评论。

采纳的回答

KSSV
KSSV 2018-7-30
X = (1:1:5)'; % column vector of Param 1
Y = (1:1:10)'; % column vector of Param 2
Z = sin((1:1:50))'; % example of 1D data, but in real case it is point by point (not a function like sin(x,y), cos or any).
shape_Z = reshape(Z, length(X), length(Y));% in 2D representation
surf(X,Y,shape_Z')
shading interp

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by