3D样条插值Matlab [英] 3D Spline Interpolation Matlab

查看:107
本文介绍了3D样条插值Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个3D阵列:

 A=[
12751   4616    15915
15864   4622    15667
12877   4683    21050
15816   4668    21253
11374   5006    18495
16995   5466    18493
11638   4880    20023
17078   4938    20006
11576   4886    17011
];

 B=[
12402   2138    15743
10285   3175    15851
10237   3084    21052
12130   2129    21299
8074    3802    18505
14515   1623    18497
8415    3713    19856
14462   1120    20061
8340    3711    17145
14483   1157    16990];

并且我想在Matlab中使用Interp3在它们之间进行样条或3D插值.如何在VI = interp3(X,Y,Z,V,XI,YI,ZI)中定义V?

and I want to do spline or 3D interpolation between them using Interp3 in Matlab.How should I define V in VI = interp3(X,Y,Z,V,XI,YI,ZI)?

yy = spline(x,Y,xx)中的Y.

推荐答案

我不太了解您的数据,BA的功能(反之亦然)吗?而且,这些阵列似乎是1D而不是3D.你能澄清一下吗?

I don't quite understand your data, is B a function of A (or visa versa)? Also, those arrays appear to be 1D, not 3D. Can you clarify this?

在您的函数调用中

yy = spline(x, Y, xx)

Y是要插入的因变量:Yx的函数,并且上述函数调用的结果是在xx返回Y的值.作为一个维度的示例,请尝试

Y is the dependent variable which you are interpolating: Y is a function of x and the result of the above function call is to return the value of Y at xx. As an example in one dimension, try

x = linspace(0., 2.*pi, 100);
Y = sin(x);

% What is the value of Y (or sin(x)) at pi/2?
xx = pi/2.;
yy = spline(x, Y, xx); % This should result in yy = 1.000

有关更多信息,请参见 spline文档以及使用此功能的示例.

Check out the spline documentation for more information and examples of using this function.

现在,此功能仅适用于一维拟合,并且(我假设)等效于yy = interp1(x, Y, xx, 'spline').如果要进行三维查找,则必须使用interp3,它将上述示例推广到3D.因此,我们不仅有一个独立的坐标x,还有两个yz,还有三个要执行查找的点的坐标:xxyy.您要插值的函数必须是坐标(x, y, z)的3D函数.尝试,例如:

Now this function is only for 1D fitting, and is (I presume) equivalent to yy = interp1(x, Y, xx, 'spline'). If you want to do a three dimensional lookup, you'll have to use interp3, which generalises the above example to 3D. So rather than just one independent coordinate x, we have two more, y, and z and three coordinates for the point at which we want to perform the look up: xx, yy and zz. The function you are interpolating must be a 3D function of the coordinates (x, y, z). Try, as an example:

x = linspace(-1., 1., 100); y = x; z = x;
[X, Y, Z] = meshgrid(x, y, z);
s = exp(-sqrt(X.^2 + Y.^2 + Z.^2));

sinterp = interp3(x, y, z, s, 0., 0., 0.) % Should give sinterp = 0.9827

这篇关于3D样条插值Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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