plotting x,y,z vertices as mesh

조회 수: 2 (최근 30일)
steamrice
steamrice 2020년 3월 10일
댓글: steamrice 2020년 3월 11일
Hello there,
I have a .xls file that contains x,y,z vertics. The sequence goes something like this: x0,y0,z0,x1,y2,z2,..........x1000,y1000,z1000 (1000data points for each x,y,z)
I am wondering is it possbile to plot all the data using mesh? I plotted only x0,y0,z0 using one of the solutions I reading using trimesh, but there is line between instead of dots. https://www.mathworks.com/matlabcentral/answers/220-3d-plot-from-imported-excel-data
That's what I have so far:
clc;clear;close all;
test = xlsread('data.xls');
x=test(:,2);
y=test(:,3);
z=test(:,4);
x = rand(100,1); % Sample x data
y = rand(100,1); % Sample y data
z = exp(-(x-0.5).^2-(y-0.5).^2); % Sample z data (a 2-D Gaussian)
tri = delaunay(x,y); % Create a 2-D triangular mesh
trimesh(tri,x,y,z); % Plot the mesh in 3-D
Any suggestions and helps please?
Thanks in advance
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 3월 10일
That approach should work, provided that you remove those 'Sample' lines.
Can you attach your data.xls for testing?

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

답변 (1개)

KSSV
KSSV 2020년 3월 10일
clc;clear;close all;
test = xlsread('data.xls');
x=test(:,2);
y=test(:,3);
z=test(:,4);
tri = delaunay(x,y); % Create a 2-D triangular mesh
figure
trimesh(tri,x,y,z); % Plot the mesh in 3-D
figure
triplot(tri,x,y);
figure
trisurf(tri,x,y,z); % Plot the surface in 3-D
shading interp
  댓글 수: 9
steamrice
steamrice 2020년 3월 11일
Thanks!
steamrice
steamrice 2020년 3월 11일
I am also just wondering if its possbile to label the x0,y0,z0,x1,y1,z1.....for each data point? Would it be a massive point?

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by