如何在 MATLAB 中使用不规则间隔的数据绘制冲浪图?
我知道我可以通过以下方式在 MATLAB 中创建 3D 曲面图:
x = linspace(1,10,100);
y = linspace(10,20,100);
[X Y] = meshgrid(x,y);
Z = X * Y;
surf(X,Y,Z);
但这要求生成的高度图的所有节点都对齐。我有一组具有任意点 (x,y) 和高度 (z) 的数据。有没有一种简单的方法来绘制图形,以类似于冲浪的方式在点之间生成曲面?
I know I can create a 3D surface plot in MATLAB by doing:
x = linspace(1,10,100);
y = linspace(10,20,100);
[X Y] = meshgrid(x,y);
Z = X * Y;
surf(X,Y,Z);
But this requires that all the nodes for the height map generated line up. I have a set of data which has arbitrary points (x,y) and a height (z). Is there a simple way to plot a graph which will generate a surface between the points in a similar fashion to surf
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,经过一番搜寻,我设法回答了我自己的问题:
您可以使用
trisurf
函数:如果您有密集的数据,您将需要进行
shading interp
(或其他值) ,检查doc shading
),这样就不会因为网格而出现黑色斑点。Appologies, after some hunting I managed to answer my own question:
You can use the
trisurf
function:If you have dense data you will want to do
shading interp
(or another value, checkdoc shading
) so you don't get a black blob due to the grid.看来您已经通过使用 DELAUNAY 和 TRISURF 生成并绘制三角剖分表面。
作为替代方案,您还可以将规则间隔的网格适合不均匀间隔的点,以生成可以使用 SURF 命令。我讨论如何使用 TriScatteredInterp< /strong> class (或已弃用的函数 GRIDDATA )在我的答案到关于SO的另一个问题。
It looks like you've found your answer by using DELAUNAY and TRISURF to generate and plot a triangulated surface.
As an alternative, you could also fit a regularly-spaced grid to your nonuniformly-spaced points in order to generate a surface that can be plotted with the SURF command. I discuss how this can be done using the TriScatteredInterp class (or the deprecated function GRIDDATA) in my answer to this other question on SO.