如何利用matlab插值! 20

如何利用matlab对已知的矩阵进行插值啊?我有一个已知的m行,4列的矩阵,矩阵的前三列为空间x,y,z坐标值,第4列为空间点(x,y,z)的对应的函数值,该函数由于太专... 如何利用matlab对已知的矩阵进行插值啊?
我有一个已知的m行,4列的矩阵,矩阵的前三列为空间x,y,z坐标值,第4列为空间点(x,y,z)的对应的函数值,该函数由于太专业了,我目前为止还写不出来!然后我还有一个待求矩阵同样为4列,有n行,前三列为坐标值,第4列为希望通过插值获得的函数值,可是我不知如何来编写?网上的例题我看到的都是等距插值,我这坐标值也没有什么规律啊!求哪位matlab高手来指点迷津啊!
可能我的阐述的有点问题。我再细化一下我的问题:
已知量:
我有一个已知的m行,4列的矩阵A,其前三列为已知的点的空间坐标值(x,y,z),而第四列为每个点对应的函数值。由于该函数关系很专业,我一时还写不出来。
我还有一个矩阵B,有n行,4列,其前三列为空间点的坐标值(x,y,z)。

未知量:
矩阵B的第四列!

我是希望通过Matlab的插值函数来进行运算!请朋友们注意,空间点的坐标值并不满足等差数列,等比数列等数学关系!

感谢xiaomol_ckt朋友的回答,对我有一定启发!但有些误会我的本意了!
展开
 我来答
122173382
2009-04-13 · TA获得超过241个赞
知道答主
回答量:222
采纳率:0%
帮助的人:0
展开全部
n维插值用interpn
看看帮助吧:
interpn

N-D data interpolation (table lookup)
Syntax

VI = interpn(X1,X2,X3,...,V,Y1,Y2,Y3,...)
VI = interpn(V,Y1,Y2,Y3,...)
VI = interpn(V,ntimes)
VI = interpn(...,method)
VI = interpn(...,method,extrapval)
Description

VI = interpn(X1,X2,X3,...,V,Y1,Y2,Y3,...) interpolates to find VI, the values of the underlying multidimensional function V at the points in the arrays Y1, Y2, Y3, etc. For an n-dimensional array V, interpn is called with 2*N+1 arguments. Arrays X1, X2, X3, etc. specify the points at which the data V is given. Out of range values are returned as NaNs. Y1, Y2, Y3, etc. must be arrays of the same size, or vectors. Vector arguments that are not the same size, and have mixed orientations (i.e. with both row and column vectors) are passed through ndgrid to create the Y1, Y2, Y3, etc. arrays. interpn works for all n-dimensional arrays with 2 or more dimensions.

VI = interpn(V,Y1,Y2,Y3,...) interpolates as above, assuming X1 = 1:size(V,1), X2 = 1:size(V,2), X3 = 1:size(V,3), etc.

VI = interpn(V,ntimes) expands V by interleaving interpolates between each element, working recursively for ntimes iterations. interpn(V) is the same as interpn(V,1).

VI = interpn(...,method) specifies alternative methods:

'nearest'

Nearest neighbor interpolation

'linear'

Linear interpolation (default)

'spline'

Cubic spline interpolation

'cubic'

Cubic interpolation, as long as data is uniformly-spaced. Otherwise, this method is the same as 'spline'.

VI = interpn(...,method,extrapval) specifies a method and a value for VI outside of the domain created by X1, X2, .... Thus, VI equals extrapval for any value of Y1, Y2,... that is not spanned by X1, X2,... respectively. You must specify a method to use extrapval. The default method is 'linear'.

interpn requires that X1, X2, X3, ... be monotonic and plaid (as if they were created using ndgrid). X1, X2, X3, and so on can be non-uniformly spaced.
Discussion

All the interpolation methods require that X1,X2, X3 ... be monotonic and have the same format ("plaid") as if they were created using ndgrid. X1,X2,X3,... and Y1, Y2, Y3, etc. can be non-uniformly spaced. For faster interpolation when X1, X2, X3, etc. are equally spaced and monotonic, use the methods '*linear', '*cubic', or '*nearest'.
Examples

Start by defining an anonymous function to compute :

f = @(x,y,z,t) t.*exp(-x.^2 - y.^2 - z.^2);

Build the lookup table by evaluating the function f on a grid constructed by ndgrid:

[x,y,z,t] = ndgrid(-1:0.2:1,-1:0.2:1,-1:0.2:1,0:2:10);
v = f(x,y,z,t);

Now construct a finer grid:

[xi,yi,zi,ti] = ndgrid(-1:0.05:1,-1:0.08:1,-1:0.05:1, ...
0:0.5:10);

Compute the spline interpolation at xi, yi, zi, and ti:

vi = interpn(x,y,z,t,v,xi,yi,zi,ti,'spline');

Plot the interpolated function, and then create a movie from the plot:

nframes = size(ti, 4);
for j = 1:nframes
slice(yi(:,:,:,j), xi(:,:,:,j), zi(:,:,:,j), ...
vi(:,:,:,j),0,0,0);
caxis([0 10]);
M(j) = getframe;
end
movie(M);
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ZESTRON
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸... 点击进入详情页
本回答由ZESTRON提供
xiaomol_ckt
2009-04-07 · TA获得超过216个赞
知道答主
回答量:41
采纳率:0%
帮助的人:0
展开全部
这是一个三维的插值问题,直接调用相应的函数
VI = interp3(X,Y,Z,V,XI,YI,ZI);
其中输入的数据X,Y,Z为给出点的三个变量,V为该点对应的值,XI,YI,ZI为要通过插值得到的点的坐标。
n为A的行数,X=A(1:n,1);Y=A(1:n,2);Z=A(1:n,3);V=(A1:n,4);对于你待求的矩阵B前三列应该是给出的吧,于是XI=B(1:n,1);YI=B(1:n,2);ZI=B(1:n,3);于是就得到啦。 B(1:n,1)=VI;
其实是不是等距插值都不是关键,关键是要X,Y,Z,V的维数相同,XI,YI,ZI的维数相同。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
日向淳正
2009-04-03 · TA获得超过2811个赞
知道大有可为答主
回答量:2770
采纳率:0%
帮助的人:1392万
展开全部
[X,Y] = meshgrid(-3:.25:3);
Z = peaks(X,Y);
[XI,YI] = meshgrid(-3:.125:3);
ZI = interp2(X,Y,Z,XI,YI);
mesh(X,Y,Z), hold, mesh(XI,YI,ZI+15)
hold off
axis([-3 3 -3 3 -5 20])
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式