How to create a good looking surface plot with inconsistent mesh size?

조회 수: 20 (최근 30일)
meslier1986
meslier1986 2017년 6월 27일
편집: Benjamin Becker 2017년 6월 28일
I have data that forms a 3-dimensional surface that was gathered with an inconsistent mesh size. NOTE: I've now edited this post so that the data file is attached and the image files showing my attempt at plots are shown below.
An inconsistent mesh size was used in order to examine fine details. I would like to create a nice looking surface plot (maybe using interpolation?) to include in a publication. You can locate my data file here: https://pastebin.com/tKTzLSkL. EDIT: The data file is now attached to this post. I've posted some images below, with descriptions of what I've tried, so that folks have a better idea of what I'm talking about and struggling with. Here's an image of what a scatter plot of my data looks like:
I'm pretty inexperienced with matlab and don't know what I'm doing. I've been able to create a plot in which a triangular mesh connects all of my data points, but the color scheme looks pretty ugly. It's certainly not something I'd put on a slide for a presentation, let alone in a publication.
Here's my attempt at a triangular mesh in matlab:
Here's the code I tried using to generate the triangular mesh plot (note: I stored my data in a matrix called 'largecomp'):
x=largecomp(:,1);
y=largecomp(:,2);
gridDelaunay=delaunay(x,y);
trisurf(gridDelaunay,x,y,z,'EdgeColor','none')
  댓글 수: 6
meslier1986
meslier1986 2017년 6월 28일
Thank you for responding! I'm very suspicious of the spikes on the right hand side, but aware of their presence. I'm going to be looking at exactly what happened there.
In the meantime, do you mind sending me your code that you used to generate the image you posted? Since I am a total beginner at this, I'm still kind of lost on how to generate what you posted.
Again, thanks!!
KSSV
KSSV 2017년 6월 28일
data = load('data.txt') ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
tri = delaunay(x,y);
trisurf(tri,x,y,z) ;
Are you sure that your data is correct?

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

답변 (1개)

Benjamin Becker
Benjamin Becker 2017년 6월 28일
편집: Benjamin Becker 2017년 6월 28일
You could also have a look at the MATLAB function scatteredInterpolant. It does linear interpolation over a non-regular grid.
[x,y,z] = textread('data.txt','%f %f %f');
F = scatteredInterpolant(x,y,z,'linear','nearest');
x = linspace(min(x),max(x),200);
y = linspace(min(y),max(y),200);
[X,Y] = meshgrid(x,y);
Z = F(X,Y);
figure
mesh(X,Y,Z)
The figure then looks like this:
If you want to change the color take a look at the MATLAB function
colormap
As a first step it might be good to clean the data.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by