3D plot help

2 visualizaciones (últimos 30 días)
laurent jalabert
laurent jalabert el 30 de Jul. de 2018
Comentada: laurent jalabert el 30 de Jul. de 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 comentarios
madhan ravi
madhan ravi el 30 de Jul. de 2018
Editada: madhan ravi el 30 de Jul. de 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 el 30 de Jul. de 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

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 30 de Jul. de 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

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by