如何从Matlab中的坐标值计算三角形插值? [英] How to calculate a triangular interpolation from values in coordinates in Matlab?

查看:336
本文介绍了如何从Matlab中的坐标值计算三角形插值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个矩阵,其中第一列和第二列与坐标相关,第三列与一个值相关,我该如何插值第三列的值以创建iscurves和colorbar范围?

If I have a matrix with first and second columns related to coordinates and third one related to a value, how could I interpolate third column values creating iscurves and colorbar ranges?

M=[
342854  657145  309
342996  657287  73
343137  657428  84
342006  657145  1122
342147  657287  777
342289  657428  426
342430  657570  638
342571  657711  200
342713  657852  787
341723  657711  1141
341864  657852  555
342006  657994  1157
342147  658135  355
342289  658277  374
341299  658135  467
341440  658277  672
341582  658418  459
341723  658560  735
341864  658701  781
341016  658701  1233
341157  658842  218
341299  658984  539
341370  659054  1351];

并获得类似附件的图片

and obtain something like the attached image

推荐答案

由于数据不在统一的网格中,因此需要使用griddata进行插值.

As your data is not in an uniform grid, you need to use griddata for interpolation.

[xq,yq]=meshgrid(linspace(min(M(:,1)),max(M(:,1)),100),linspace(min(M(:,2)),max(M(:,2)),100));
zq=griddata(M(:,1),M(:,2),M(:,3),xq(:),yq(:),'cubic'); %cubic for smoother results
[c,h]=contourf(xq,yq,reshape(zq,100,100));
clabel(c,h);

这篇关于如何从Matlab中的坐标值计算三角形插值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆