how to plot a 3D surface from N by 3 matrix

조회 수: 19 (최근 30일)
mohamed Faraj
mohamed Faraj 2019년 8월 22일
댓글: AdamG2013468 2019년 8월 22일
I have a matrix with dimensions N by 3, for example 100 rows and 3 columns. Each row correspondds to the 3D location of a point, i.e., we have 100 points. I want to pot the 100 points and connect them as a surface.

채택된 답변

AdamG2013468
AdamG2013468 2019년 8월 22일
Try,
S = size(matrix); %"matrix being your generic matrix
[X, Y] = meshgrid(1:S(2), 1:S(1));
Z = matrix; %e.g. 100 by 3 matrix
surf(X,Y,Z)
  댓글 수: 2
mohamed Faraj
mohamed Faraj 2019년 8월 22일
Hi Adam. The X matrix is 100 by 3 matrix of the form [1 2 3;1 2 3;1 2 3 ....]
AdamG2013468
AdamG2013468 2019년 8월 22일
You should be able to use the code above, adjusting for your desired X, Y, Z axes values accordingly.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

darova
darova 2019년 8월 22일
Look for griddata()

카테고리

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