3D plot help

2 views (last 30 days)
laurent jalabert
laurent jalabert on 30 Jul 2018
Commented: laurent jalabert on 30 Jul 2018
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 Comments
madhan ravi
madhan ravi on 30 Jul 2018
Edited: madhan ravi on 30 Jul 2018
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 on 30 Jul 2018
... 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

Sign in to comment.

Accepted Answer

KSSV
KSSV on 30 Jul 2018
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

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!