how to plot a 2D matrix to a 3D graph
이전 댓글 표시
given a 2D matrix of size( x * y ) where each element contains a numeric value Z , how to plot the Z value in a 3D graph as a function of both x and y such that Z = matrix(x,y) ?
I have tried using meshgrid to create a 2D array of size(x,y) and defined a new function F = matrix(x,y) and finally used surf(x,y,F) to plot the data but it gave me an empty graph.
댓글 수: 4
John Chilleri
2017년 2월 1일
편집: John Chilleri
2017년 2월 1일
If you look into the surf command, you see that given three matrices:
surf(X, Y, Z)
The corresponding elements of X, Y, Z represent the x location, y location, and Z value, respectively, so you would need a 120x160 X, and a 120x160 Y matrix with your desired locations corresponding to your Z values.
Furthermore, the connections are made to the 4 nearest neighbors, which is in a matrix sense, the elements directly above, below, and beside each element.
raed khader
2017년 2월 1일
John Chilleri
2017년 2월 1일
Good to hear!
Amit Kumar
2020년 10월 14일
Dear John,
what is 120x160 X matrix. I have the same problem. For eg. I have a matrix
2 3 2.5 5 7 6
4 8 5.6 7 8 9
8 9 4.7 4 2 8
All these value are of Z. then what should be X and Y matrix
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!