3D plot help

조회 수: 2 (최근 30일)
laurent jalabert
laurent jalabert 2018년 7월 30일
댓글: 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