Matrix to Surf Incorrect

8 ビュー (過去 30 日間)
Sclay748
Sclay748 2020 年 10 月 28 日
編集済み: Swetha Polemoni 2020 年 11 月 2 日
Hello, I have a 4x3 matrix. When I use the surf function, it does not plot properly. I want:
  • X Axis = 1st Column
  • Y Axis = 2nd Column
  • Z Axis = 3rd Column
Attached is a screenshot of the code and what shows up.
Thank you!

回答 (1 件)

Swetha Polemoni
Swetha Polemoni 2020 年 11 月 2 日
編集済み: Swetha Polemoni 2020 年 11 月 2 日
Hi,
As per my understanding you want these following points to be plotted.
(x,y,z)=> (15,50,0.1576549),(25,20,0.1581748),(25,50,0.157905),(25,80,0.157428).
  • Understanding the working of "surf".
For a given matrix A, surf(A) will plot A(i,j) at i on x-axis and j on y axis where i and j are row and column number respectively.
Consider the following example for better understanding
Let A=[a,b;c,d]
surf(A) will surface plot the element b of matrix A at (1,1) as x and y coordinates.
X=[15 50 0.1576549; 25 20 0.1581748; 25 50 0.157905; 25 80 0.157428 ]
According to the above explanation, surf(X) will surface plot
the following points (1,1,15),(2,1,25),(1,2,50) etc. As per my understanding, surf will not work for your application.
  • Undersatnding the working of "plot3"
(x,y,z)=> (15,50,0.1576549),(25,20,0.1581748),(25,50,0.157905),(25,80,0.157428)
For plotting these points "plot3" can be used.
Following code snippet is for better understanding.
X=[15 50 0.1576549; 25 20 0.1581748; 25 50 0.157905; 25 80 0.157428 ]
plot3(X(:,1),X(:,2),X(:,3))

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by