How to calculate a triangular interpolation from values in coordinates in Matlab?

纵饮孤独 提交于 2020-01-06 14:22:15

问题


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


回答1:


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);



来源:https://stackoverflow.com/questions/51670744/how-to-calculate-a-triangular-interpolation-from-values-in-coordinates-in-matlab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!