필터 지우기
필터 지우기

Creating Surface Plot from a Matrix with 3 Columns

조회 수: 60 (최근 30일)
Sarah
Sarah 2018년 7월 30일
댓글: MOHAMED GHAZI 2022년 4월 3일
How do you create a surface plot using a matrix with 3 columns in Matlab? The first column would be the x-values, the second column would be the y-values, and the third column would be the z-values for the surface plot.
  댓글 수: 3
Sarah
Sarah 2018년 7월 30일
I am generating data from a loop. Here is a simple example from the loop:
0.5000 0.5000 66.9052
0.5000 1.0000 57.3591
1.0000 0.5000 76.7805
1.0000 1.0000 66.9052
KSSV
KSSV 2018년 7월 30일
More data is needed.

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

채택된 답변

KSSV
KSSV 2018년 7월 30일
A = [0.5000 0.5000 66.9052
0.5000 1.0000 57.3591
1.0000 0.5000 76.7805
1.0000 1.0000 66.9052] ;
x = A(:,1) ; y = A(:,2) ; z = A(:,3) ;
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
surf(X,Y,Z)
%%unstructured
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)
  댓글 수: 11
Hans Kramer
Hans Kramer 2021년 3월 30일
Thank you for the answer.
MOHAMED GHAZI
MOHAMED GHAZI 2022년 4월 3일
KSSV how can I trisurf this matrix I used your email program it does not work.
P1=[1;0;1];
P2= [2; 3;2];
P3= [-3;1;2];
P4= [6;2;3];
MatrixP=[1 2 -3 6 ;0 3 1 2;1 2 2 3];
%%structured
[X,Y] = meshgrid(MatrixP) ;
B = unique(A,'rows');
figure
surf(X,Y,Z)
%%unstructured
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)

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

추가 답변 (1개)

KSSV
KSSV 2021년 10월 9일
x = speed ; y = Torque ; z = bsfc ;
%%structured
xi = unique(x) ; yi = unique(y) ;
[X,Y] = meshgrid(xi,yi) ;
Z = reshape(z,size(X)) ;
figure
pcolor(X,Y,Z)
%% griddata
xi = linspace(min(x),max(x));
yi = linspace(min(y),max(y)) ;
[X,Y] = meshgrid(xi,yi) ;
Z = griddata(x,y,z,X,Y)
pcolor(X,Y,Z)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by